Zelda Classic Coverage Report


Directory: src/
File: src/zc/ffscript.cpp
Date: 2023-11-03 10:30:11
Exec Total Coverage
Lines: 5117 27508 18.6%
Functions: 294 1071 27.5%
Branches: 3028 21514 14.1%

Line Branch Exec Source
1 #include <deque>
2 #include <string>
3 #include <sstream>
4 #include <math.h>
5 #include <cstdio>
6 //
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <fstream>
12 #include <filesystem>
13 #include <fmt/format.h>
14 //
15
16 #include "base/qrs.h"
17 #include "base/dmap.h"
18 #include "base/msgstr.h"
19 #include "base/packfile.h"
20 #include "base/misctypes.h"
21 #include "base/initdata.h"
22 #include "zc/zc_ffc.h"
23 #include "zc/zc_sys.h"
24 #include "zc/jit.h"
25 #include "zc/script_debug.h"
26 #include "base/zc_alleg.h"
27 #include "base/zc_math.h"
28 #include "base/zc_array.h"
29 #include "zc/ffscript.h"
30 #include "zc/render.h"
31 #include "zc/zc_subscr.h"
32 #include <time.h>
33 #include "zc/script_drawing.h"
34 #include "base/util.h"
35 #include "zc/ending.h"
36 #include "base/module.h"
37 #include "zc/combos.h"
38 #include "drawing.h"
39 #include "base/colors.h"
40 #include "pal.h"
41 #include "zinfo.h"
42 #include "subscr.h"
43 #include "zc_list_data.h"
44 #include <sstream>
45
46 #ifdef _WIN32
47 #define SCRIPT_FILE_MODE (_S_IREAD | _S_IWRITE)
48 #else
49 #include <fcntl.h>
50 #include <unistd.h>
51 #include <iostream>
52 #define SCRIPT_FILE_MODE (S_ISVTX | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
53 #endif
54
55 //Define this register, so it can be treated specially
56 #define NUL 5
57 #define MAX_ZC_ARRAY_SIZE 214748
58
59 // #define _SCRIPT_COUNTER
60
61 #ifdef _SCRIPT_COUNTER
62 static int64_t script_timer[NUMCOMMANDS];
63 static int64_t script_execount[NUMCOMMANDS];
64 #endif
65
66 using namespace util;
67 using std::ostringstream;
68
69 extern byte use_dwm_flush;
70 uint8_t using_SRAM = 0;
71
72 int32_t hangcount = 0;
73 bool can_neg_array = true;
74
75 extern byte monochrome_console;
76
77 115 static std::set<script_id> seen_scripts;
78 115 static std::map<script_id, ScriptDebugHandle> script_debug_handles;
79 ScriptDebugHandle* runtime_script_debug_handle;
80 115 static std::map<std::pair<script_data*, refInfo*>, JittedScriptHandle*> jitted_scripts;
81 int32_t jitted_uncompiled_command_count;
82
83 115 CScriptDrawingCommands scriptdraws;
84 115 FFScript FFCore;
85 ZModule zcm;
86 zcmodule moduledata;
87 115 script_bitmaps scb;
88
3/4
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29325 times.
✓ Branch 3 taken 115 times.
29440 user_file script_files[MAX_USER_FILES];
89
3/4
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29325 times.
✓ Branch 3 taken 115 times.
29440 user_dir script_dirs[MAX_USER_DIRS];
90
3/4
✓ Branch 0 taken 24696020 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24695905 times.
✓ Branch 3 taken 115 times.
24696020 user_object script_objects[MAX_USER_OBJECTS];
91
3/4
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29325 times.
✓ Branch 3 taken 115 times.
29440 user_stack script_stacks[MAX_USER_STACKS];
92 115 user_rng nulrng;
93 115 user_rng script_rngs[MAX_USER_RNGS];
94 115 zc_randgen script_rnggens[MAX_USER_RNGS];
95 115 user_paldata script_paldatas[MAX_USER_PALDATAS];
96
97 FONT *get_zc_font(int index);
98
99 int32_t combopos_modified = -1;
100 static word combo_id_cache[7*176] = {0};
101
102 57600 void user_dir::clear()
103 {
104 57600 user_abstract_obj::clear();
105 57600 filepath = "";
106 57600 reserved = false;
107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57600 times.
57600 if(list)
108 {
109 list->clear();
110 free(list);
111 list = NULL;
112 }
113 57600 }
114 void user_dir::setPath(const char* buf)
115 {
116 if(!list)
117 {
118 list = (FLIST *) malloc(sizeof(FLIST));
119 }
120 reserved = true;
121 filepath = std::string(buf) + "/";
122 regulate_path(filepath);
123 list->load(filepath.c_str());
124 }
125
126 int32_t CScriptDrawingCommands::GetCount()
127 {
128 al_trace("current number of draws is: %d\n", count);
129 return count;
130 }
131 //Advances the game frame without checking 'Quit' variable status.
132 //Used for making scripts such as Player's onWin and onDeath scripts
133 //run for multiple frames.
134
135 void FFScript::Waitframe(bool allowwavy, bool sfxcleanup)
136 {
137 if(zcmusic!=NULL)
138 {
139 zcmusic_poll();
140 }
141 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
142
143 while(Paused && !Advance && !Quit)
144 {
145 // have to call this, otherwise we'll get an infinite loop
146 syskeys();
147 // to keep fps constant
148 updatescr(allowwavy);
149 zc_throttle_fps();
150
151 #ifdef _WIN32
152
153 if(use_dwm_flush)
154 {
155 do_DwmFlush();
156 }
157
158 #endif
159
160 // to keep music playing
161 if(zcmusic!=NULL)
162 {
163 zcmusic_poll();
164 }
165 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
166
167 update_hw_screen();
168 }
169
170 //if(Quit)
171 // return;
172 /*
173 if(Playing && game->get_time()<MAXTIME)
174 game->change_time(1);
175 */
176 Advance=false;
177 ++frame;
178
179 syskeys();
180 // Someday... maybe install a Turbo button here?
181 updatescr(allowwavy);
182 zc_throttle_fps();
183
184 #ifdef _WIN32
185
186 if(use_dwm_flush)
187 {
188 do_DwmFlush();
189 }
190
191 #endif
192
193 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
194 if(sfxcleanup)
195 sfx_cleanup();
196 }
197
198 18513311 mapscr* GetMapscr(int32_t mapref)
199 {
200
6/15
✓ Branch 0 taken 30619 times.
✓ Branch 1 taken 17379802 times.
✓ Branch 2 taken 135332 times.
✓ Branch 3 taken 16153 times.
✓ Branch 4 taken 1957 times.
✓ Branch 5 taken 949448 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
18513311 switch(mapref)
201 {
202 30619 case MAPSCR_TEMP0: return FFCore.tempScreens[0]; //Temp layer 0
203 135332 case MAPSCR_TEMP1: return FFCore.tempScreens[1]; //Temp layer 1
204 16153 case MAPSCR_TEMP2: return FFCore.tempScreens[2]; //Temp layer 2
205 1957 case MAPSCR_TEMP3: return FFCore.tempScreens[3]; //Temp layer 3
206 949448 case MAPSCR_TEMP4: return FFCore.tempScreens[4]; //Temp layer 4
207 case MAPSCR_TEMP5: return FFCore.tempScreens[5]; //Temp layer 5
208 case MAPSCR_TEMP6: return FFCore.tempScreens[6]; //Temp layer 6
209 case MAPSCR_SCROLL0: return FFCore.ScrollingScreens[0]; //Temp scrolllayer 0
210 case MAPSCR_SCROLL1: return FFCore.ScrollingScreens[1]; //Temp scrolllayer 1
211 case MAPSCR_SCROLL2: return FFCore.ScrollingScreens[2]; //Temp scrolllayer 2
212 case MAPSCR_SCROLL3: return FFCore.ScrollingScreens[3]; //Temp scrolllayer 3
213 case MAPSCR_SCROLL4: return FFCore.ScrollingScreens[4]; //Temp scrolllayer 4
214 case MAPSCR_SCROLL5: return FFCore.ScrollingScreens[5]; //Temp scrolllayer 5
215 case MAPSCR_SCROLL6: return FFCore.ScrollingScreens[6]; //Temp scrolllayer 6
216 default:
217 {
218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17379802 times.
17379802 if(mapref < 0) return NULL; //Bad negative value
219 17379802 else return &TheMaps[mapref]; //Standard mapdata
220 }
221 }
222 18513311 }
223
224 int32_t getMap(int32_t ref)
225 {
226 switch(ref)
227 {
228 case MAPSCR_TEMP0:
229 return currmap+1;
230 case MAPSCR_TEMP1:
231 return FFCore.tempScreens[0]->layermap[0];
232 case MAPSCR_TEMP2:
233 return FFCore.tempScreens[0]->layermap[1];
234 case MAPSCR_TEMP3:
235 return FFCore.tempScreens[0]->layermap[2];
236 case MAPSCR_TEMP4:
237 return FFCore.tempScreens[0]->layermap[3];
238 case MAPSCR_TEMP5:
239 return FFCore.tempScreens[0]->layermap[4];
240 case MAPSCR_TEMP6:
241 return FFCore.tempScreens[0]->layermap[5];
242 case MAPSCR_SCROLL0:
243 return scrolling_map+1;
244 case MAPSCR_SCROLL1:
245 return FFCore.ScrollingScreens[0]->layermap[0];
246 case MAPSCR_SCROLL2:
247 return FFCore.ScrollingScreens[0]->layermap[1];
248 case MAPSCR_SCROLL3:
249 return FFCore.ScrollingScreens[0]->layermap[2];
250 case MAPSCR_SCROLL4:
251 return FFCore.ScrollingScreens[0]->layermap[3];
252 case MAPSCR_SCROLL5:
253 return FFCore.ScrollingScreens[0]->layermap[4];
254 case MAPSCR_SCROLL6:
255 return FFCore.ScrollingScreens[0]->layermap[5];
256 default:
257 return (ref / MAPSCRS + 1);
258 }
259 }
260 int32_t getScreen(int32_t ref)
261 {
262 switch(ref)
263 {
264 case MAPSCR_TEMP0:
265 return currscr;
266 case MAPSCR_TEMP1:
267 return FFCore.tempScreens[0]->layerscreen[0];
268 case MAPSCR_TEMP2:
269 return FFCore.tempScreens[0]->layerscreen[1];
270 case MAPSCR_TEMP3:
271 return FFCore.tempScreens[0]->layerscreen[2];
272 case MAPSCR_TEMP4:
273 return FFCore.tempScreens[0]->layerscreen[3];
274 case MAPSCR_TEMP5:
275 return FFCore.tempScreens[0]->layerscreen[4];
276 case MAPSCR_TEMP6:
277 return FFCore.tempScreens[0]->layerscreen[5];
278 case MAPSCR_SCROLL0:
279 return scrolling_scr;
280 case MAPSCR_SCROLL1:
281 return FFCore.ScrollingScreens[0]->layerscreen[0];
282 case MAPSCR_SCROLL2:
283 return FFCore.ScrollingScreens[0]->layerscreen[1];
284 case MAPSCR_SCROLL3:
285 return FFCore.ScrollingScreens[0]->layerscreen[2];
286 case MAPSCR_SCROLL4:
287 return FFCore.ScrollingScreens[0]->layerscreen[3];
288 case MAPSCR_SCROLL5:
289 return FFCore.ScrollingScreens[0]->layerscreen[4];
290 case MAPSCR_SCROLL6:
291 return FFCore.ScrollingScreens[0]->layerscreen[5];
292 default:
293 return (ref % MAPSCRS);
294 }
295 }
296
297 dword get_subref(int sub, byte ty, byte pg = 0, word ind = 0)
298 {
299 byte s;
300 if(sub == -1) //special; load current
301 {
302 s = new_sub_indexes[ty];
303 if(s < 0) return 0;
304 }
305 else if(unsigned(sub) < 256)
306 s = sub;
307 else return 0;
308 ++ty; //type is offset by 1
309 return (s<<24)|(pg<<16)|((ty&0x7)<<13)|(ind&0x1FFF);
310 }
311 std::tuple<byte,int8_t,byte,word> from_subref(dword ref)
312 {
313 byte type = (ref>>13)&0x07;
314 if(!type)
315 return { 0, -1, 0, 0 };
316
317 byte sub = (ref>>24)&0xFF;
318 byte pg = (ref>>16)&0xFF;
319 word ind = (ref)&0x1FFF;
320 return { sub, type-1, pg, ind };
321 }
322
323 std::tuple<ZCSubscreen*,SubscrPage*,SubscrWidget*,byte> load_subscreen_ref(dword ref)
324 {
325 auto [sub,ty,pg,ind] = from_subref(ref);
326 ZCSubscreen* sbscr = nullptr;
327 SubscrPage* sbpg = nullptr;
328 SubscrWidget* sbwidg = nullptr;
329 switch(ty)
330 {
331 case sstACTIVE:
332 if(sub < subscreens_active.size())
333 sbscr = &subscreens_active[sub];
334 break;
335 case sstPASSIVE:
336 if(sub < subscreens_passive.size())
337 sbscr = &subscreens_passive[sub];
338 break;
339 case sstOVERLAY:
340 if(sub < subscreens_overlay.size())
341 sbscr = &subscreens_overlay[sub];
342 break;
343 }
344 if(sbscr)
345 {
346 if(pg < sbscr->pages.size())
347 sbpg = &sbscr->pages[pg];
348 }
349 else return { nullptr, nullptr, nullptr, -1 }; //no subscreen
350 if(sbpg)
351 {
352 if(ind < sbpg->size())
353 sbwidg = sbpg->at(ind);
354 }
355 return { sbscr, sbpg, sbwidg, ty };
356 }
357 std::pair<ZCSubscreen*,byte> load_subdata(dword ref)
358 {
359 auto [sub,_pg,_widg,ty] = load_subscreen_ref(ref);
360 return { sub, ty };
361 }
362 std::pair<SubscrPage*,byte> load_subpage(dword ref)
363 {
364 auto [_sub,pg,_widg,ty] = load_subscreen_ref(ref);
365 return { pg, ty };
366 }
367 std::pair<SubscrWidget*,byte> load_subwidg(dword ref)
368 {
369 auto [_sub,_pg,widg,ty] = load_subscreen_ref(ref);
370 return { widg, ty };
371 }
372
373 #include "zconsole/ConsoleLogger.h"
374
375 //no ifdef here
376 115 CConsoleLoggerEx coloured_console;
377 extern CConsoleLoggerEx zscript_coloured_console;
378
379 int32_t FFScript::UpperToLower(std::string *s)
380 {
381 if ( s->size() < 1 )
382 {
383 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", s->size());
384 return 0;
385 }
386 for ( size_t q = 0; q < s->size(); ++q )
387 {
388 //if ( s->at(q) >= 'A' || s->at(q) <= 'Z' )
389 //{
390 // s->at(q) += 32;
391 //}
392 s->at(q) += 32 * (s->at(q) >= 'A' && s->at(q) <= 'Z');
393 }
394 return 1;
395 }
396
397 int32_t FFScript::LowerToUpper(std::string *s)
398 {
399 if ( s->size() < 1 )
400 {
401 Z_scripterrlog("String passed to LowerToUpper() is too small. Size is: %d \n", s->size());
402 return 0;
403 }
404 for ( size_t q = 0; q < s->size(); ++q )
405 {
406 //if ( s->at(q) >= 'a' || s->at(q) <= 'z' )
407 //{
408 // s->at(q) -= 32;
409 //}
410 s->at(q) -= 32 * (s->at(q) >= 'a' && s->at(q) <= 'z');
411 }
412 return 1;
413 }
414
415 int32_t FFScript::ConvertCase(std::string *s)
416 {
417 if ( s->size() < 1 )
418 {
419 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", s->size());
420 return 0;
421 }
422 for ( size_t q = 0; q < s->size(); ++q )
423 {
424 if ( s->at(q) >= 'a' || s->at(q) <= 'z' )
425 {
426 s->at(q) -= 32;
427 }
428 else if ( s->at(q) >= 'A' || s->at(q) <= 'Z' )
429 {
430 s->at(q) += 32;
431 }
432 }
433 zprint("FFScript::ConvertCase(std::string s), post-conversion, string is: %s\n", s->c_str());
434 return 1;
435 }
436
437 bool FFScript::isNumber(char chr)
438 {
439 if ( chr >= '0' )
440 {
441 if ( chr <= '9' ) return true;
442 }
443 return false;
444 }
445
446 int32_t FFScript::ilen(char *p)
447 {
448 int32_t ret = 0; int32_t pos = 0;
449 if(p[pos] == '-')
450 ret++;
451 for(; FFCore.isNumber(p[pos + ret]); ++ret);
452 return ret;
453 }
454
455 int32_t FFScript::zc_strlen(char *p)
456 {
457 int32_t count = 0;
458
459 while(*p!='\0')
460 {
461 count++;
462 p++;
463 }
464
465 return count;
466 }
467
468 int32_t FFScript::atox(char *ip_str)
469 {
470 char tmp[2]={'2','\0'};
471 int32_t op_val=0, i=0, ip_len = FFCore.zc_strlen(ip_str);
472
473 if(strncmp(ip_str, "0x", 2) == 0)
474 {
475 ip_str +=2;
476 ip_len -=2;
477 }
478
479 for(i=0;i<ip_len;i++)
480 {
481 op_val *= 0x10;
482 switch(ip_str[i])
483 {
484 case 'a':
485 op_val += 0xa;
486 break;
487 case 'b':
488 op_val += 0xb;
489 break;
490 case 'c':
491 op_val += 0xc;
492 break;
493 case 'd':
494 op_val += 0xd;
495 break;
496 case 'e':
497 op_val += 0xe;
498 break;
499 case 'f':
500 op_val += 0xf;
501 break;
502 case '0':
503 case '1':
504 case '2':
505 case '3':
506 case '4':
507 case '5':
508 case '6':
509 case '7':
510 case '8':
511 case '9':
512 tmp[0] = ip_str[i];
513 op_val += atoi(tmp);
514 break;
515 default :
516 op_val += 0x0;
517 break;
518 }
519 }
520 return op_val;
521 }
522
523 char runningItemScripts[256] = {0};
524
525 //item *FFCore.temp_ff_item = NULL;
526 //enemy *FFCore.temp_ff_enemy = NULL;
527 //weapon *FFCore.temp_ff_lweapon = NULL;
528 //weapon *FFCore.temp_ff_eweapon = NULL;
529
530 #include "zc/zelda.h"
531 #include "particles.h"
532 #include "zc/hero.h"
533 extern int32_t directItemA;
534 extern int32_t directItemB;
535 extern int32_t directItemX;
536 extern int32_t directItemY;
537
538 #include "zc/guys.h"
539 #include "gamedata.h"
540 #include "zc/zc_init.h"
541 #include "base/zsys.h"
542 #include "base/misctypes.h"
543 #include "zc/title.h"
544 #include "zscriptversion.h"
545
546 #include "pal.h"
547 #include "base/zdefs.h"
548 #include "zc/rendertarget.h"
549
550 #include "zc/zc_custom.h"
551 #include "qst.h"
552
553 #ifdef _MSC_VER
554 #pragma warning ( disable : 4800 ) //int32_t to bool town. population: lots.
555 #endif
556
557 #define NUMSHOPS 256
558 #define NUMINFOSHOPS 511
559
560 //! New datatype vars for 2.54:
561
562 //spritedata sp->member
563
564
565 using std::string;
566
567 extern particle_list particles;
568 extern HeroClass Hero;
569 extern char *guy_string[];
570 extern int32_t skipcont;
571
572 PALETTE tempgreypal; //Palettes go here. This is used for Greyscale() / Monochrome()
573 PALETTE userPALETTE[256]; //Palettes go here. This is used for Greyscale() / Monochrome()
574 PALETTE tempblackpal; //Used for storing the palette while fading to black
575
576 115 FFScript ffengine;
577
578 byte FF_hero_action; //This way, we can make safe replicas of internal Hero actions to be set by script.
579
580 int32_t FF_screenbounds[4]; //edges of the screen, left, right, top, bottom used for where to scroll.
581 int32_t FF_screen_dimensions[4]; //height, width, displaywidth, displayheight
582 int32_t FF_subscreen_dimensions[4];
583 int32_t FF_eweapon_removal_bounds[4]; //left, right, top, bottom coordinates for automatic eweapon removal.
584 int32_t FF_lweapon_removal_bounds[4]; //left, right, top, bottom coordinates for automatic lweapon removal.
585 int32_t FF_clocks[FFSCRIPTCLASS_CLOCKS]; //Will be used for Heroaction, anims, and so forth
586 byte ScriptDrawingRules[SCRIPT_DRAWING_RULES];
587 int32_t FF_UserMidis[NUM_USER_MIDI_OVERRIDES]; //MIDIs to use for Game Over, and similar to override system defaults.
588
589 int32_t get_int_arr(const int32_t ptr, int32_t indx);
590 void set_int_arr(const int32_t ptr, int32_t indx, int32_t val);
591 int32_t sz_int_arr(const int32_t ptr);
592
593 //We gain some speed by not passing as arguments
594 int32_t sarg1 = 0;
595 int32_t sarg2 = 0;
596 std::vector<int32_t> *sargvec;
597 std::string *sargstr;
598 refInfo *ri = NULL;
599 script_data *curscript = NULL;
600 int32_t(*stack)[MAX_SCRIPT_REGISTERS] = NULL;
601 std::vector<int32_t> zs_vargs;
602 ScriptType curScriptType;
603 word curScriptNum;
604 int32_t curScriptIndex;
605 bool script_funcrun = false;
606 std::string* destructstr = nullptr;
607
608 static std::vector<ScriptType> curScriptType_cache;
609 static std::vector<int32_t> curScriptNum_cache;
610 static std::vector<int32_t> curScriptIndex_cache;
611 static std::vector<int32_t> sarg1cache;
612 static std::vector<int32_t> sarg2cache;
613 static std::vector<std::vector<int32_t>*> sargvec_cache;
614 static std::vector<std::string*> sargstr_cache;
615 static std::vector<refInfo*> ricache;
616 static std::vector<script_data*> sdcache;
617 static std::vector<int32_t(*)[MAX_SCRIPT_REGISTERS]> stackcache;
618 10 void push_ri()
619 {
620 10 sarg1cache.push_back(sarg1);
621 10 sarg2cache.push_back(sarg2);
622 10 curScriptType_cache.push_back(curScriptType);
623 10 curScriptNum_cache.push_back(curScriptNum);
624 10 curScriptIndex_cache.push_back(curScriptIndex);
625 10 sargvec_cache.push_back(sargvec);
626 10 sargstr_cache.push_back(sargstr);
627 10 ricache.push_back(ri);
628 10 sdcache.push_back(curscript);
629 10 stackcache.push_back(stack);
630 10 }
631 10 void pop_ri()
632 {
633 10 sarg1 = sarg1cache.back(); sarg1cache.pop_back();
634 10 sarg2 = sarg2cache.back(); sarg2cache.pop_back();
635 10 curScriptType = curScriptType_cache.back(); curScriptType_cache.pop_back();
636 10 curScriptNum = curScriptNum_cache.back(); curScriptNum_cache.pop_back();
637 10 curScriptIndex = curScriptIndex_cache.back(); curScriptIndex_cache.pop_back();
638 10 sargvec = sargvec_cache.back(); sargvec_cache.pop_back();
639 10 sargstr = sargstr_cache.back(); sargstr_cache.pop_back();
640 10 ri = ricache.back(); ricache.pop_back();
641 10 curscript = sdcache.back(); sdcache.pop_back();
642 10 stack = stackcache.back(); stackcache.pop_back();
643 10 }
644
645 static int32_t numInstructions = 0; // Used to detect hangs
646 static bool scriptCanSave = true;
647
648 std::vector<refInfo*> genericActiveData;
649 std::vector<int32_t(*)[MAX_SCRIPT_REGISTERS]> generic_active_stack;
650 bool gen_active_doscript = false, gen_active_initialized = false;
651
652 285241 struct ScriptEngineData {
653 refInfo ref;
654 int32_t stack[MAX_SCRIPT_REGISTERS];
655 // This is used as a boolean for all but ScriptType::Item.
656 285241 byte doscript = true;
657 bool waitdraw;
658 bool initialized;
659
660 2575479 void reset()
661 {
662 // No need to zero the stack.
663 2575479 ref = refInfo();
664 2575479 doscript = true;
665 2575479 waitdraw = false;
666 2575479 initialized = false;
667 2575479 }
668 };
669
670 // (type, index) => ScriptEngineData
671 115 static std::map<std::pair<ScriptType, word>, ScriptEngineData> scriptEngineDatas;
672
673 349533337 static ScriptEngineData& get_script_engine_data(ScriptType type, int index)
674 {
675
7/8
✓ Branch 0 taken 333242832 times.
✓ Branch 1 taken 16290505 times.
✓ Branch 2 taken 333242832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 316968865 times.
✓ Branch 5 taken 16273967 times.
✓ Branch 6 taken 17616 times.
✓ Branch 7 taken 316951249 times.
349533337 if (type == ScriptType::DMap || type == ScriptType::OnMap || type == ScriptType::ScriptedPassiveSubscreen || type == ScriptType::ScriptedActiveSubscreen)
676 {
677 // `index` is used for dmapref, not for different script engine data.
678 32582088 index = 0;
679 32582088 }
680
1/2
✓ Branch 0 taken 349533337 times.
✗ Branch 1 not taken.
349533337 if (type == ScriptType::EngineSubscreen)
681 {
682 // `index` is used for subdataref, not for different script engine data.
683 index = 0;
684 }
685
686 349533337 return scriptEngineDatas[{type, index}];
687 }
688
689 40 static ScriptEngineData& get_script_engine_data(ScriptType type)
690 {
691 40 return scriptEngineDatas[{type, 0}];
692 }
693
694 408 void FFScript::clear_script_engine_data()
695 {
696 408 scriptEngineDatas.clear();
697 408 }
698
699 2112119 void FFScript::reset_script_engine_data(ScriptType type, int index)
700 {
701 2112119 get_script_engine_data(type, index).reset();
702 2112119 }
703
704 163913 void FFScript::clear_script_engine_data(ScriptType type, int index)
705 {
706
4/8
✓ Branch 0 taken 163913 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163913 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 163913 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 163913 times.
163913 if (type == ScriptType::DMap || type == ScriptType::OnMap || type == ScriptType::ScriptedPassiveSubscreen || type == ScriptType::ScriptedActiveSubscreen)
707 {
708 // `index` is used for dmapref, not for different script engine data.
709 index = 0;
710 }
711
1/2
✓ Branch 0 taken 163913 times.
✗ Branch 1 not taken.
163913 if (type == ScriptType::EngineSubscreen)
712 {
713 // `index` is used for subdataref, not for different script engine data.
714 index = 0;
715 }
716
717 163913 auto it = scriptEngineDatas.find({type, index});
718
2/2
✓ Branch 0 taken 163861 times.
✓ Branch 1 taken 52 times.
163913 if (it != scriptEngineDatas.end())
719 {
720 52 scriptEngineDatas.erase(it);
721 52 }
722 163913 }
723
724 58862 void FFScript::clear_script_engine_data_of_type(ScriptType type)
725 {
726 38037596 std::erase_if(scriptEngineDatas, [&](auto& kv) { return kv.first.first == type; });
727 58862 }
728
729 194 refInfo& FFScript::ref(ScriptType type, int index)
730 {
731 194 return get_script_engine_data(type, index).ref;
732 }
733
734 32458054 byte& FFScript::doscript(ScriptType type, int index)
735 {
736 32458054 return get_script_engine_data(type, index).doscript;
737 }
738
739 267138830 bool& FFScript::waitdraw(ScriptType type, int index)
740 {
741 267138830 return get_script_engine_data(type, index).waitdraw;
742 }
743
744 // Returns true if registers had to be initialized.
745 8919206 static bool set_current_script_engine_data(ScriptType type, int script, int index)
746 {
747 8919206 bool got_initialized = false;
748
749 8919206 auto& data = get_script_engine_data(type, index);
750 8919206 ri = &data.ref;
751 8919206 stack = &data.stack;
752
753
8/12
✓ Branch 0 taken 270765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38089 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4681611 times.
✓ Branch 5 taken 4287 times.
✓ Branch 6 taken 3889258 times.
✓ Branch 7 taken 13182 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 12104 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 9910 times.
8919206 switch (type)
754 {
755 case ScriptType::FFC:
756 {
757 4681611 curscript = ffscripts[script];
758
759
2/2
✓ Branch 0 taken 4665957 times.
✓ Branch 1 taken 15654 times.
4681611 if (!data.initialized)
760 {
761 15654 got_initialized = true;
762 15654 memcpy(ri->d, tmpscr->ffcs[index].initd, 8 * sizeof(int32_t));
763 15654 memcpy(ri->a, tmpscr->ffcs[index].inita, 2 * sizeof(int32_t));
764 15654 data.initialized = true;
765 15654 }
766
767 4681611 ri->ffcref = index;
768 }
769 4681611 break;
770
771 // case ScriptType::NPC:
772 // {
773 // int32_t npc_index = GuyH::getNPCIndex(i);
774 // enemy *w = (enemy*)guys.spr(npc_index);
775 // ri = &(w->scrmem->scriptData);
776 // curscript = guyscripts[w->script];
777 // stack = &(w->scrmem->stack);
778 // ri->guyref = i;
779
780 // if (!w->initialised)
781 // {
782 // got_initialized = true;
783 // for ( int32_t q = 0; q < 8; q++ )
784 // {
785 // ri->d[q] = w->initD[q];
786 // }
787 // w->initialised = 1;
788 // }
789 // }
790 // break;
791
792 // case ScriptType::Lwpn:
793 // {
794 // int32_t lwpn_index = LwpnH::getLWeaponIndex(i);
795 // weapon *w = (weapon*)Lwpns.spr(lwpn_index);
796 // ri = &(w->scrmem->scriptData);
797 // curscript = lwpnscripts[w->weaponscript];
798 // stack = &(w->scrmem->stack);
799 // ri->lwpn = i;
800
801 // if (!w->initialised)
802 // {
803 // got_initialized = true;
804 // for ( int32_t q = 0; q < 8; q++ )
805 // {
806 // ri->d[q] = w->weap_initd[q]; //w->initiald[q];
807 // }
808 // w->initialised = 1;
809 // }
810 // }
811 // break;
812
813 // case ScriptType::Ewpn:
814 // {
815 // int32_t ewpn_index = EwpnH::getEWeaponIndex(i);
816 // weapon *w = (weapon*)Ewpns.spr(ewpn_index);
817 // ri = &(w->scrmem->scriptData);
818 // curscript = ewpnscripts[w->weaponscript];
819 // stack = &(w->scrmem->stack);
820 // ri->ewpn = i;
821
822 // if (!w->initialised)
823 // {
824 // got_initialized = true;
825 // for ( int32_t q = 0; q < 8; q++ )
826 // {
827 // ri->d[q] = w->weap_initd[q];
828 // }
829 // w->initialised = 1;
830 // }
831 // }
832 // break;
833
834 // case ScriptType::ItemSprite:
835 // {
836 // int32_t the_index = ItemH::getItemIndex(i);
837 // item *w = (item*)items.spr(the_index);
838 // ri = &(w->scrmem->scriptData);
839 // curscript = itemspritescripts[w->script];
840 // stack = &(w->scrmem->stack);
841 // ri->itemref = i;
842
843 // if (!w->initialised)
844 // {
845 // got_initialized = true;
846 // for ( int32_t q = 0; q < 8; q++ )
847 // {
848 // ri->d[q] = w->initD[q];
849 // }
850 // w->initialised = 1;
851 // }
852 // }
853 // break;
854
855 case ScriptType::Item:
856 {
857 4287 int32_t i = index;
858 4287 int32_t new_i = 0;
859
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 4093 times.
4287 bool collect = ( ( i < 1 ) || (i == COLLECT_SCRIPT_ITEM_ZERO) );
860
3/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 4093 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
4287 new_i = ( collect ) ? (( i != COLLECT_SCRIPT_ITEM_ZERO ) ? (i * -1) : 0) : i;
861
862 4287 curscript = itemscripts[script];
863
864
2/2
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 1009 times.
4287 if (!data.initialized)
865 {
866 1009 got_initialized = true;
867
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 memcpy(ri->d, ( collect ) ? itemsbuf[new_i].initiald : itemsbuf[i].initiald, 8 * sizeof(int32_t));
868
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 memcpy(ri->a, ( collect ) ? itemsbuf[new_i].initiala : itemsbuf[i].initiala, 2 * sizeof(int32_t));
869 1009 data.initialized = true;
870 1009 }
871
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 4093 times.
4287 ri->idata = ( collect ) ? new_i : i; //'this' pointer
872 }
873 4287 break;
874
875 case ScriptType::Global:
876 {
877 3889258 curscript = globalscripts[script];
878 }
879 3889258 break;
880
881 // case ScriptType::Generic:
882 // {
883 // user_genscript& scr = user_scripts[script];
884 // stack = &scr.stack;
885 // ri = &scr.ri;
886 // ri->genericdataref = script;
887 // curscript = genericscripts[script];
888 // scr.waitevent = false;
889 // if(!scr.initialized)
890 // {
891 // got_initialized = true;
892 // scr.initialized = true;
893 // memcpy(ri->d, scr.initd, 8 * sizeof(int32_t));
894 // }
895 // }
896 // break;
897
898 // case ScriptType::GenericFrozen:
899 // {
900 // ri = genericActiveData.back();
901 // ri->genericdataref = script;
902 // curscript = genericscripts[script];
903 // stack = generic_active_stack.back();
904 // if(!gen_active_initialized)
905 // {
906 // got_initialized = true;
907 // gen_active_initialized = true;
908 // memcpy(ri->d, user_scripts[script].initd, 8 * sizeof(int32_t));
909 // }
910 // }
911 // break;
912
913 case ScriptType::Player:
914 {
915 270765 curscript = playerscripts[script];
916 }
917 270765 break;
918
919 case ScriptType::DMap:
920 {
921 13182 curscript = dmapscripts[script];
922 13182 ri->dmapsref = index;
923 //how do we clear initialised on dmap change?
924
2/2
✓ Branch 0 taken 13169 times.
✓ Branch 1 taken 13 times.
13182 if ( !data.initialized )
925 {
926 13 got_initialized = true;
927
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 13 times.
117 for ( int32_t q = 0; q < 8; q++ )
928 {
929 104 ri->d[q] = DMaps[ri->dmapsref].initD[q];// * 10000;
930 104 }
931 13 data.initialized = true;
932 13 }
933 }
934 13182 break;
935
936 case ScriptType::OnMap:
937 {
938 curscript = dmapscripts[script];
939 ri->dmapsref = index;
940 if (!data.initialized)
941 {
942 got_initialized = true;
943 for ( int32_t q = 0; q < 8; q++ )
944 {
945 ri->d[q] = DMaps[ri->dmapsref].onmap_initD[q];
946 }
947 data.initialized = true;
948 }
949 }
950 break;
951
952 case ScriptType::ScriptedActiveSubscreen:
953 {
954 12104 curscript = dmapscripts[script];
955 12104 ri->dmapsref = index;
956
2/2
✓ Branch 0 taken 12064 times.
✓ Branch 1 taken 40 times.
12104 if (!data.initialized)
957 {
958 40 got_initialized = true;
959
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 40 times.
360 for ( int32_t q = 0; q < 8; q++ )
960 {
961 320 ri->d[q] = DMaps[ri->dmapsref].sub_initD[q];
962 320 }
963 40 data.initialized = true;
964 40 }
965 }
966 12104 break;
967
968 case ScriptType::ScriptedPassiveSubscreen:
969 {
970 curscript = dmapscripts[script];
971 ri->dmapsref = index;
972 if (!data.initialized)
973 {
974 got_initialized = true;
975 for ( int32_t q = 0; q < 8; q++ )
976 {
977 ri->d[q] = DMaps[ri->dmapsref].sub_initD[q];
978 }
979 data.initialized = true;
980 }
981 }
982 break;
983 case ScriptType::EngineSubscreen:
984 {
985 curscript = subscreenscripts[script];
986 ri->subdataref = get_subref(-1, sstACTIVE);
987 auto [ptr,_ty] = load_subdata(ri->subdataref);
988
989 if (ptr && !data.initialized)
990 {
991 got_initialized = true;
992 for ( int32_t q = 0; q < 8; q++ )
993 {
994 ri->d[q] = ptr->initd[q];
995 }
996 data.initialized = true;
997 }
998 }
999 break;
1000
1001 case ScriptType::Screen:
1002 {
1003 9910 curscript = screenscripts[script];
1004
1005
2/2
✓ Branch 0 taken 9887 times.
✓ Branch 1 taken 23 times.
9910 if (!data.initialized)
1006 {
1007 23 got_initialized = true;
1008
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 23 times.
207 for ( int32_t q = 0; q < 8; q++ )
1009 {
1010 184 ri->d[q] = tmpscr->screeninitd[q];// * 10000;
1011 184 }
1012 23 data.initialized = true;
1013 23 }
1014 }
1015 9910 break;
1016
1017 case ScriptType::Combo:
1018 {
1019 38089 curscript = comboscripts[script];
1020
1021 38089 int32_t pos = combopos_ref_to_pos(index);
1022 38089 int32_t lyr = combopos_ref_to_layer(index);
1023 38089 int32_t id = FFCore.tempScreens[lyr]->data[pos];
1024
2/2
✓ Branch 0 taken 37715 times.
✓ Branch 1 taken 374 times.
38089 if (!data.initialized)
1025 {
1026 374 got_initialized = true;
1027 374 memset(ri->d, 0, 8 * sizeof(int32_t));
1028
2/2
✓ Branch 0 taken 2992 times.
✓ Branch 1 taken 374 times.
3366 for ( int32_t q = 0; q < 8; q++ )
1029 2992 ri->d[q] = combobuf[id].initd[q];
1030 374 data.initialized = true;
1031 374 }
1032
1033 38089 ri->combosref = id; //'this' pointer
1034 38089 ri->comboposref = index; //used for X(), Y(), Layer(), and so forth.
1035 38089 break;
1036 }
1037 }
1038
1039 8919206 return got_initialized;
1040 }
1041
1042 //Sprite script data
1043 refInfo npcScriptData[256];
1044 refInfo lweaponScriptData[256]; //should this be lweapon and eweapon, separate stacks?
1045 refInfo eweaponScriptData[256]; //should this be lweapon and eweapon, separate stacks?
1046 refInfo itemactiveScriptData[256];
1047
1048 int32_t ffmisc[MAXFFCS][16];
1049
1050
3/4
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58765 times.
✓ Branch 3 taken 115 times.
58880 user_genscript user_scripts[NUMSCRIPTSGENERIC];
1051 int32_t genscript_timing = SCR_TIMING_START_FRAME;
1052 static word max_valid_genscript;
1053 static dword max_valid_object;
1054
1055 363 void user_genscript::quit()
1056 {
1057 363 doscript = false;
1058
1/2
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
363 if(indx > -1)
1059 {
1060 363 FFCore.deallocateAllScriptOwned(ScriptType::Generic, indx);
1061 363 }
1062 363 }
1063
1064 529 void countGenScripts()
1065 {
1066 529 max_valid_genscript = 0;
1067
2/2
✓ Branch 0 taken 270319 times.
✓ Branch 1 taken 529 times.
270848 for(auto q = 1; q < NUMSCRIPTSGENERIC; ++q)
1068 {
1069
3/4
✓ Branch 0 taken 270319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 270165 times.
✓ Branch 3 taken 154 times.
270319 if(genericscripts[q] && genericscripts[q]->valid())
1070 154 max_valid_genscript = q;
1071 270319 }
1072 529 }
1073 408 void countObjects()
1074 {
1075 408 max_valid_object = 0;
1076
2/2
✓ Branch 0 taken 87617184 times.
✓ Branch 1 taken 408 times.
87617592 for(auto q = 0; q < MAX_USER_OBJECTS; ++q)
1077 {
1078
1/2
✓ Branch 0 taken 87617184 times.
✗ Branch 1 not taken.
87617184 if(script_objects[q].reserved)
1079 max_valid_object = q+1;
1080 87617184 }
1081 408 }
1082 19590 void timeExitAllGenscript(byte exState)
1083 {
1084
2/2
✓ Branch 0 taken 10030080 times.
✓ Branch 1 taken 19590 times.
10049670 for(user_genscript& g : user_scripts)
1085 10030080 g.timeExit(exState);
1086 19590 }
1087 303797 void throwGenScriptEvent(int32_t event)
1088 {
1089
2/2
✓ Branch 0 taken 38892 times.
✓ Branch 1 taken 303797 times.
342689 for(auto q = 1; q <= max_valid_genscript; ++q)
1090 {
1091 38892 user_genscript& scr = user_scripts[q];
1092
2/2
✓ Branch 0 taken 12956 times.
✓ Branch 1 taken 25936 times.
38892 if(!scr.doscript) continue;
1093
2/2
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 3238 times.
12956 if(!genericscripts[q]->valid()) continue;
1094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9718 times.
9718 if(!scr.waitevent) continue;
1095 if(scr.eventstate & (1<<event))
1096 {
1097 scr.ri.d[rEXP1] = event*10000;
1098 scr.waitevent = false;
1099
1100 //Run the script!
1101 ZScriptVersion::RunScript(ScriptType::Generic, q, q);
1102 }
1103 }
1104 303797 }
1105
1106 74 void load_genscript(const gamedata& gd)
1107 {
1108
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 74 times.
37962 for(size_t q = 0; q < NUMSCRIPTSGENERIC; ++q)
1109 {
1110 37888 user_genscript& gen = user_scripts[q];
1111 37888 gen.clear();
1112 37888 gen.indx = q;
1113 37888 gen.doscript = gd.gen_doscript.get(q);
1114 37888 gen.exitState = gd.gen_exitState[q];
1115 37888 gen.reloadState = gd.gen_reloadState[q];
1116 37888 gen.eventstate = gd.gen_eventstate[q];
1117 37888 gen.initd = gd.gen_initd[q];
1118 37888 gen.data = gd.gen_data[q];
1119 37888 }
1120 74 }
1121 47 void load_genscript(const zinitdata& zd)
1122 {
1123
2/2
✓ Branch 0 taken 24064 times.
✓ Branch 1 taken 47 times.
24111 for(size_t q = 0; q < NUMSCRIPTSGENERIC; ++q)
1124 {
1125 24064 user_genscript& gen = user_scripts[q];
1126 24064 gen.clear();
1127 24064 gen.indx = q;
1128 24064 gen.doscript = zd.gen_doscript.get(q);
1129 24064 gen.exitState = zd.gen_exitState[q];
1130 24064 gen.reloadState = zd.gen_reloadState[q];
1131 24064 gen.eventstate = zd.gen_eventstate[q];
1132 24064 gen.initd = zd.gen_initd[q];
1133 24064 gen.data = zd.gen_data[q];
1134 24064 }
1135 47 }
1136
1137 void save_genscript(gamedata& gd)
1138 {
1139 for(size_t q = 0; q < NUMSCRIPTSGENERIC; ++q)
1140 {
1141 user_genscript const& gen = user_scripts[q];
1142 gd.gen_doscript.set(q, gen.doscript);
1143 gd.gen_exitState[q] = gen.exitState;
1144 gd.gen_reloadState[q] = gen.reloadState;
1145 gd.gen_eventstate[q] = gen.eventstate;
1146 gd.gen_initd[q] = gen.initd;
1147 gd.gen_data[q] = gen.data;
1148 }
1149 }
1150
1151 300466787 void FFScript::runGenericPassiveEngine(int32_t scrtm)
1152 {
1153
2/2
✓ Branch 0 taken 3460760 times.
✓ Branch 1 taken 297006027 times.
300466787 if(!max_valid_genscript) return; //No generic scripts in the quest!
1154 //zprint2("Processing timing %d\n", scrtm);
1155 3460760 bool init = (scrtm == SCR_TIMING_INIT);
1156
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3460759 times.
3460760 if(!init)
1157 {
1158
2/2
✓ Branch 0 taken 22119 times.
✓ Branch 1 taken 3438640 times.
3460759 if(genscript_timing != scrtm)
1159 {
1160 //zprint2("Generic script timing jump: expected '%d', found '%d'\n", genscript_timing, scrtm);
1161
2/2
✓ Branch 0 taken 77115 times.
✓ Branch 1 taken 22119 times.
99234 while(genscript_timing != scrtm)
1162 77115 runGenericPassiveEngine(genscript_timing);
1163 22119 }
1164 3460759 }
1165
2/2
✓ Branch 0 taken 41529120 times.
✓ Branch 1 taken 3460760 times.
44989880 for(auto q = 1; q <= max_valid_genscript; ++q)
1166 {
1167 41529120 user_genscript& scr = user_scripts[q];
1168
2/2
✓ Branch 0 taken 13843030 times.
✓ Branch 1 taken 27686090 times.
41529120 if(!scr.doscript) continue;
1169
2/2
✓ Branch 0 taken 10382275 times.
✓ Branch 1 taken 3460755 times.
13843030 if(!genericscripts[q]->valid()) continue;
1170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10382275 times.
10382275 if(scr.waitevent) continue;
1171
8/8
✓ Branch 0 taken 10382273 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 10204736 times.
✓ Branch 3 taken 177537 times.
✓ Branch 4 taken 10204389 times.
✓ Branch 5 taken 347 times.
✓ Branch 6 taken 9760653 times.
✓ Branch 7 taken 443736 times.
10382275 if(!init && (scr.waituntil > scrtm || (!scr.wait_atleast && scr.waituntil != scrtm)))
1172 9938190 continue;
1173
1174 //Run the script!
1175 444085 ZScriptVersion::RunScript(ScriptType::Generic, q, q);
1176 444085 }
1177
4/4
✓ Branch 0 taken 3460759 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3372038 times.
✓ Branch 3 taken 88721 times.
3460760 if(init || genscript_timing >= SCR_TIMING_END_FRAME)
1178 88722 genscript_timing = SCR_TIMING_START_FRAME;
1179 3372038 else ++genscript_timing;
1180 300466787 }
1181
1182 5239 void FFScript::initZScriptDMapScripts()
1183 {
1184 5239 scriptEngineDatas[{ScriptType::DMap, 0}] = ScriptEngineData();
1185 5239 scriptEngineDatas[{ScriptType::ScriptedPassiveSubscreen, 0}] = ScriptEngineData();
1186 5239 }
1187
1188 754 void FFScript::initZScriptSubscreenScript()
1189 {
1190 754 scriptEngineDatas[{ScriptType::EngineSubscreen, 0}] = ScriptEngineData();
1191 754 }
1192 5263 void FFScript::initZScriptScriptedActiveSubscreen()
1193 {
1194 5263 scriptEngineDatas[{ScriptType::ScriptedActiveSubscreen, 0}] = ScriptEngineData();
1195 5263 }
1196
1197 void FFScript::initZScriptOnMapScript()
1198 {
1199 scriptEngineDatas[{ScriptType::OnMap, 0}] = ScriptEngineData();
1200 }
1201
1202 966 void FFScript::initZScriptHeroScripts()
1203 {
1204 966 scriptEngineDatas[{ScriptType::Player, 0}] = ScriptEngineData();
1205 966 }
1206
1207 905 void FFScript::initZScriptItemScripts()
1208 {
1209
2/2
✓ Branch 0 taken 231680 times.
✓ Branch 1 taken 905 times.
232585 for ( int32_t q = 0; q < 256; q++ )
1210 {
1211 231680 auto& data = get_script_engine_data(ScriptType::Item, q);
1212 231680 data.reset();
1213
1/2
✓ Branch 0 taken 231680 times.
✗ Branch 1 not taken.
231680 data.doscript = (itemsbuf[q].flags&ITEM_PASSIVESCRIPT) && game->item[q];
1214 231680 }
1215
1216
2/2
✓ Branch 0 taken 231680 times.
✓ Branch 1 taken 905 times.
232585 for ( int32_t q = -256; q < 0; q++ )
1217 {
1218 231680 auto& data = get_script_engine_data(ScriptType::Item, q);
1219 231680 data.reset();
1220 231680 data.doscript = 0;
1221 231680 }
1222 905 }
1223
1224 2574844 static int get_mouse_state(int index)
1225 {
1226 2574844 int value = 0;
1227
1/2
✓ Branch 0 taken 2574844 times.
✗ Branch 1 not taken.
2574844 if (replay_is_replaying())
1228 {
1229 2574844 value = replay_get_mouse(index);
1230 2574844 }
1231 else if (index == 0)
1232 {
1233 value = script_mouse_x;
1234 }
1235 else if (index == 1)
1236 {
1237 value = script_mouse_y;
1238 }
1239 else if (index == 2)
1240 {
1241 value = script_mouse_z;
1242 }
1243 else if (index == 3)
1244 {
1245 value = script_mouse_b;
1246 }
1247
1248
1/2
✓ Branch 0 taken 2574844 times.
✗ Branch 1 not taken.
2574844 if (replay_is_recording())
1249 {
1250 replay_set_mouse(index, value);
1251 }
1252
1253 2574844 return value;
1254 }
1255
1256 ///----------------------------------------------//
1257 // New Mapscreen Flags Tools //
1258 ///----------------------------------------------//
1259
1260 /*
1261 void FFScript::set_mapscreenflag_state(mapscr *m, int32_t flagid, bool state)
1262 {
1263 switch(flagid)
1264 {
1265 // Room Types
1266 case MSF_INTERIOR:
1267 if ( state )
1268 m->flags6 |= 1;
1269 else m->flags6 &= ~1;
1270 break;
1271 case MSF_DUNGEON:
1272 if ( state )
1273 m->flags6 |= 2;
1274 else m->flags6 &= ~2;
1275 break;
1276 case MSF_SIDEVIEW:
1277 if ( state )
1278 m->flags7 |= 8;
1279 else m->flags7 &= ~8;
1280 break;
1281
1282 // View
1283 case MSF_INVISHERO:
1284 if ( state )
1285 m->flags3 |= 8;
1286 else m->flags3 &= ~8;
1287 break;
1288 case MSF_NOHEROMARKER:
1289 if ( state )
1290 m->flags7 |= 16;
1291 else m->flags7 &= ~16;
1292 break;
1293
1294 case MSF_NOSUBSCREEN:
1295 if ( state )
1296 m->flags3 |= 16;
1297 else m->flags3 &= ~16;
1298 break;
1299 case MSF_NOOFFSET:
1300 if ( state )
1301 m->flags3 |= 64;
1302 else m->flags3 &= ~64;
1303 break;
1304
1305 case MSF_LAYER2BG:
1306 if ( state )
1307 m->flags7 |= 2;
1308 else m->flags7 &= ~2;
1309 break;
1310 case MSF_LAYER3BG:
1311 if ( state )
1312 m->flags7 |= 1;
1313 else m->flags7 &= ~1;
1314 break;
1315 case MSF_DARKROOM:
1316 if ( state )
1317 m->flags |= 4;
1318 else m->flags &= ~4;
1319 break;
1320
1321 // Secrets
1322 case MSF_BLOCKSHUT:
1323 if ( state )
1324 m->flags |= 1;
1325 else m->flags &= ~1;
1326 break;
1327 case MSF_TEMPSECRETS:
1328 if ( state )
1329 m->flags5 |= 16;
1330 else m->flags5 &= ~16;
1331 break;
1332
1333 case MSF_TRIGPERM:
1334 if ( state )
1335 m->flags6 |= 4;
1336 else m->flags6 &= ~4;
1337 break;
1338 case MSF_ALLTRIGFLAGS:
1339 if ( state )
1340 m->flags6 |= 32;
1341 else m->flags6 &= ~32;
1342 break;
1343 // Warp
1344 case MSF_AUTODIRECT:
1345 if ( state )
1346 m->flags5 |= 4;
1347 else m->flags5 &= ~4;
1348 break;
1349 case MSF_SENDSIRECT:
1350 if ( state )
1351 m->flags5 |= 8;
1352 else m->flags5 &= ~8;
1353 break;
1354 case MSF_MAZEPATHS:
1355 if ( state )
1356 m->flags |= 64;
1357 else m->flags &= ~64;
1358 break;
1359
1360 case MSF_MAZEOVERRIDE:
1361 if ( state )
1362 m->flags8 |= 64;
1363 else m->flags8 &= ~64;
1364 break;
1365 case MSF_SPRITECARRY:
1366 if ( state )
1367 m->flags3 |= 32;
1368 else m->flags3 &= ~32;
1369 break;
1370
1371 case MSF_DIRECTTIMEDWARPS:
1372 if ( state )
1373 m->flags4 |= 4;
1374 else m->flags4 &= ~4;
1375 break;
1376
1377 case MSF_SECRETSISABLETIMEWRP:
1378 if ( state )
1379 m->flags4 |= 8;
1380 else m->flags4 &= ~8;
1381 break;
1382 case MSF_RANDOMTIMEDWARP:
1383 if ( state )
1384 m->flags5 |= 1;
1385 else m->flags5 &= ~1;
1386 break;
1387
1388 // Item
1389 case MSF_HOLDUP:
1390 if ( state )
1391 m->flags3 |= 1;
1392 else m->flags3 &= ~1;
1393 break;
1394
1395 case MSF_FALLS:
1396 if ( state )
1397 m->flags7 |= 4;
1398 else m->flags7 &= ~4;
1399 break;
1400
1401
1402 // Combo
1403 case MSF_MIDAIR:
1404 { //FIX ME!
1405 //! What the ever love of fuck mate?!
1406 // byte *f2 = &(m->flags2);
1407 // f2 >>=4;
1408 // int32_t f = 0;
1409 // f<<=1;
1410 // f |= state ? 1:0;
1411 // m->flags2 &= 0x0F;
1412 // m->flags2 |= f<<4;
1413 //if ( state )
1414 // (m->flags2>>4) |= 2;
1415 //else (m->flags2>>4) &= ~2;
1416 break;
1417 }
1418 case MSF_CYCLEINIT:
1419 if ( state )
1420 m->flags3 |= 2;
1421 else m->flags3 &= ~2;
1422 break;
1423 case MSF_IGNOREBOOTS:
1424 if ( state )
1425 m->flags5 |= 2;
1426 else m->flags5 &= ~2;
1427 break;
1428 case MSF_TOGGLERINGS:
1429 if ( state )
1430 m->flags6 |= 64;
1431 else m->flags6 &= ~64;
1432 break;
1433 // Save
1434 case MSF_SAVECONTHERE:
1435 if ( state )
1436 m->flags4 |= 64;
1437 else m->flags4 &= ~64;
1438 break;
1439 case MSF_SAVEONENTRY:
1440 if ( state )
1441 m->flags4 |= 128;
1442 else m->flags4 &= ~128;
1443 break;
1444
1445 case MSF_CONTHERE:
1446 if ( state )
1447 m->flags6 |= 8;
1448 else m->flags6 &= ~8;
1449 break;
1450
1451 case MSF_NOCONTINUEWARP:
1452 if ( state )
1453 m->flags6 |= 16;
1454 else m->flags6 &= ~16;
1455 break;
1456
1457 // FFC
1458 case MSF_WRAPFFC:
1459 if ( state )
1460 m->flags6 |= 128;
1461 else m->flags6 &= ~128;
1462 break;
1463
1464 case MSF_NOCARRYOVERFFC:
1465 if ( state )
1466 m->flags5 |= 128;
1467 else m->flags5 &= ~128;
1468 break;
1469
1470 // Whistle
1471 case MSF_STAIRS:
1472 if ( state )
1473 m->flags |= 16;
1474 else m->flags &= ~16;
1475 break;
1476 case MSF_PALCHANGE:
1477 if ( state )
1478 m->flags7 |= 64;
1479 else m->flags7 &= ~64;
1480 break;
1481 case MSF_DRYLAKE:
1482 if ( state )
1483 m->flags7 |= 128;
1484 else m->flags7 &= ~128;
1485 break;
1486
1487 // Enemies
1488 case MSF_TRAPS_IGNORE_SOLID:
1489 {
1490 //! What the ever love of fuck mate?!
1491 int32_t f = 0;
1492 f<<=2;
1493 f |= state ? 1:0;
1494 m->flags2 &= 0x0F;
1495 m->flags2 |= f<<4;
1496 break;
1497
1498 //! May be wrong : Might be 4>>4 : ~4>>4;?
1499 //if ( state )
1500 // m->(flags2>>4) |= 4;
1501 //else (flags2>>4) &= ~4;
1502 //break;
1503 }
1504 case MSF_ENEMEIS_SECRET:
1505 {
1506 //! What the ever love of fuck mate?!
1507 int32_t f = 0;
1508 f<<=3;
1509 f |= state ? 1:0;
1510 m->flags2 &= 0x0F;
1511 m->flags2 |= f<<4;
1512 break;
1513
1514 //! May be wrong : Might be 8>>4 : ~8>>4;?
1515 //if ( state )
1516 // m->(flags2>>4) |= 8;
1517 //else (flags2>>4) &= ~8;
1518 //break;
1519 }
1520 case MSF_INVISIBLEENEMIES:
1521 if ( state )
1522 m->flags3 |= 4;
1523 else m->flags3 &= ~4;
1524 case MSF_EMELIESALWAYSRETURN:
1525 if ( state )
1526 m->flags3 |= 128;
1527 else m->flags3 &= ~128;
1528 break;
1529 case MSF_ENEMIES_ITEM:
1530 if ( state )
1531 m->flags |= 2;
1532 else m->flags &= ~2;
1533 break;
1534
1535 case MSF_ENEMIES_SECRET_PERM:
1536 if ( state )
1537 m->flags4 |= 16;
1538 else m->flags4 &= ~16;
1539 break;
1540
1541 case MSF_SPAWN_ZORA:
1542 if ( state )
1543 m->enemyflags |= 1;
1544 else m->enemyflags &= ~1;
1545 break;
1546 case MSF_SPAWN_CORNERTRAP:
1547 if ( state )
1548 m->enemyflags |= 2;
1549 else m->enemyflags &= ~2;
1550 break;
1551 case MSF_SPAWN_MIDDLETRAP:
1552 if ( state )
1553 m->enemyflags |= 4;
1554 else m->enemyflags &= ~4;
1555 break;
1556 case MSF_SPAWN_ROCK:
1557 if ( state )
1558 m->enemyflags |= 8;
1559 else m->enemyflags &= ~8;
1560 break;
1561 case MSF_SPAWN_SHOOTER:
1562 if ( state )
1563 m->enemyflags |= 16;
1564 else m->enemyflags &= ~16;
1565 break;
1566
1567 case MSF_RINGLEADER:
1568 if ( state )
1569 m->enemyflags |= 32;
1570 else m->enemyflags &= ~32;
1571 break;
1572 case MSF_ENEMYHASITEM:
1573 if ( state )
1574 m->enemyflags |= 64;
1575 else m->enemyflags &= ~64;
1576 break;
1577 case MSF_ENEMYISBOSS:
1578 if ( state )
1579 m->enemyflags |= 128;
1580 else m->enemyflags &= ~128;
1581 break;
1582
1583 // Misc
1584 case MSF_ALLOW_LADDER:
1585 if ( state )
1586 m->flags |= 32;
1587 else m->flags &= ~32;
1588 break;
1589 case MSF_NO_DIVING:
1590 if ( state )
1591 m->flags5 |= 64;
1592 else m->flags5 &= ~64;
1593 break;
1594
1595 case MSF_LENSEFFECT:
1596 if ( state )
1597 m->flags8 |= 32;
1598 else m->flags8 &= ~32;
1599 break;
1600
1601 case MSF_SFXONENTRY:
1602 if ( state )
1603 m->flags |= 128;
1604 else m->flags &= ~128;
1605 break;
1606
1607
1608 // Custom / Script
1609 case MSF_SCRIPT1:
1610 if ( state )
1611 m->flags8 |= 1;
1612 else m->flags8 &= ~1;
1613 break;
1614 case MSF_SCRIPT2:
1615 if ( state )
1616 m->flags8 |= 2;
1617 else m->flags8 &= ~2;
1618 break;
1619 case MSF_SCRIPT3:
1620 if ( state )
1621 m->flags8 |= 4;
1622 else m->flags8 &= ~4;
1623 break;
1624 case MSF_SCRIPT4:
1625 if ( state )
1626 m->flags8 |= 8;
1627 else m->flags8 &= ~8;
1628 break;
1629 case MSF_SCRIPT5:
1630 if ( state )
1631 m->flags8 |= 16;
1632 else m->flags8 &= ~16;
1633 break;
1634
1635 //This is a dummy proc, but may have been used at one point in older versions.
1636 case MSF_DUMMY_8:
1637 if ( state )
1638 m->flags |= 8;
1639 else m->flags &= ~8;
1640 break;
1641
1642 default: Z_scripterrlog("Illegal flag value (%d) passed to SetMapscreenFlag", flagid);
1643 }
1644 }
1645
1646 int32_t FFScript::get_mapscreenflag_state(mapscr *m, int32_t flagid)
1647 {
1648 switch(flagid)
1649 {
1650 // Room Types
1651 case MSF_INTERIOR:
1652 return (m->flags6&1) ? 1 : 0;
1653 case MSF_DUNGEON:
1654 return (m->flags6&2) ? 1 : 0;
1655 case MSF_SIDEVIEW:
1656 return (m->flags7&8) ? 1 : 0;
1657
1658 // View
1659 case MSF_INVISHERO:
1660 return (m->flags3&8) ? 1 : 0;
1661 case MSF_NOHEROMARKER:
1662 return (m->flags7&16) ? 1 : 0;
1663
1664 case MSF_NOSUBSCREEN:
1665 return (m->flags3&16) ? 1 : 0;
1666 case MSF_NOOFFSET:
1667 return (m->flags3&64) ? 1 : 0;
1668
1669 case MSF_LAYER2BG:
1670 return (m->flags7&2) ? 1 : 0;
1671 case MSF_LAYER3BG:
1672 return (m->flags7&1) ? 1 : 0;
1673 case MSF_DARKROOM:
1674 return (m->flags&4) ? 1 : 0;
1675
1676 // Secrets
1677 case MSF_BLOCKSHUT:
1678 return (m->flags&1) ? 1 : 0;
1679 case MSF_TEMPSECRETS:
1680 return (m->flags5&16) ? 1 : 0;
1681 case MSF_TRIGPERM:
1682 return (m->flags6&4) ? 1 : 0;
1683 case MSF_ALLTRIGFLAGS:
1684 return (m->flags6&32) ? 1 : 0;
1685
1686 // Warp
1687 case MSF_AUTODIRECT:
1688 return (m->flags5&4) ? 1 : 0;
1689 case MSF_SENDSIRECT:
1690 return (m->flags5&8) ? 1 : 0;
1691 case MSF_MAZEPATHS:
1692 return (m->flags&64) ? 1 : 0;
1693
1694 case MSF_MAZEOVERRIDE:
1695 return (m->flags8&64) ? 1 : 0;
1696 case MSF_SPRITECARRY:
1697 return (m->flags3&32) ? 1 : 0;
1698 case MSF_DIRECTTIMEDWARPS:
1699 return (m->flags4&4) ? 1 : 0;
1700 case MSF_SECRETSISABLETIMEWRP:
1701 return (m->flags4&8) ? 1 : 0;
1702
1703 case MSF_RANDOMTIMEDWARP:
1704 return (m->flags5&1) ? 1 : 0;
1705
1706 // Item
1707 case MSF_HOLDUP:
1708 return (m->flags3&1) ? 1 : 0;
1709 case MSF_FALLS:
1710 return (m->flags7&4) ? 1 : 0;
1711
1712 // Combo
1713 case MSF_MIDAIR:
1714 return ((m->flags2>>4)&2) ? 1 : 0;
1715 case MSF_CYCLEINIT:
1716 return (m->flags3&2) ? 1 : 0;
1717 case MSF_IGNOREBOOTS:
1718 return (m->flags5&2) ? 1 : 0;
1719 case MSF_TOGGLERINGS:
1720 return (m->flags6&64) ? 1 : 0;
1721 // Save
1722 case MSF_SAVECONTHERE:
1723 return (m->flags4&64) ? 1 : 0;
1724 case MSF_SAVEONENTRY:
1725 return (m->flags4&128) ? 1 : 0;
1726
1727 case MSF_CONTHERE:
1728 return (m->flags6&8) ? 1 : 0;
1729
1730 case MSF_NOCONTINUEWARP:
1731 return (m->flags6&16) ? 1 : 0;
1732
1733 // FFC
1734 case MSF_WRAPFFC:
1735 return (m->flags6&128) ? 1 : 0;
1736
1737 case MSF_NOCARRYOVERFFC:
1738 return (m->flags5&128) ? 1 : 0;
1739
1740 // Whistle
1741 case MSF_STAIRS:
1742 return (m->flags&16) ? 1 : 0;
1743 case MSF_PALCHANGE:
1744 return (m->flags7&64) ? 1 : 0;
1745 case MSF_DRYLAKE:
1746 return (m->flags7&128) ? 1 : 0;
1747
1748 // Enemies
1749 case MSF_TRAPS_IGNORE_SOLID:
1750 //! May be wrong : Might be 4>>4 : ~4>>4;?
1751 return ((m->flags2>>4)&4) ? 1 : 0;
1752
1753 case MSF_ENEMEIS_SECRET:
1754 //! May be wrong : Might be 8>>4 : ~8>>4;?
1755 return ((m->flags2>>4)&8) ? 1 : 0;
1756
1757 case MSF_ENEMIES_SECRET_PERM:
1758 return (m->flags4&16) ? 1 : 0;
1759
1760 case MSF_SPAWN_ZORA:
1761 return (m->enemyflags&1) ? 1 : 0;
1762
1763 case MSF_SPAWN_CORNERTRAP:
1764 return (m->enemyflags&2) ? 1 : 0;
1765
1766 case MSF_SPAWN_MIDDLETRAP:
1767 return (m->enemyflags&3) ? 1 : 0;
1768
1769 case MSF_SPAWN_ROCK:
1770 return (m->enemyflags&4) ? 1 : 0;
1771
1772 case MSF_SPAWN_SHOOTER:
1773 return (m->enemyflags&16) ? 1 : 0;
1774
1775 case MSF_RINGLEADER:
1776 return (m->enemyflags&32) ? 1 : 0;
1777
1778 case MSF_ENEMYHASITEM:
1779 return (m->enemyflags&64) ? 1 : 0;
1780 case MSF_ENEMYISBOSS:
1781 return (m->enemyflags&128) ? 1 : 0;
1782
1783 case MSF_INVISIBLEENEMIES:
1784 return (m->flags3&4) ? 1 : 0;
1785 case MSF_EMELIESALWAYSRETURN:
1786 return (m->flags3&128) ? 1 : 0;
1787
1788 case MSF_ENEMIES_ITEM:
1789 return (m->flags&2) ? 1 : 0;
1790
1791 // Misc
1792 case MSF_ALLOW_LADDER:
1793 return (m->flags&32) ? 1 : 0;
1794 case MSF_NO_DIVING:
1795 return (m->flags5&64) ? 1 : 0;
1796
1797 case MSF_LENSEFFECT:
1798 return (m->flags8&32) ? 1 : 0;
1799
1800 case MSF_SFXONENTRY:
1801 return (m->flags&128) ? 1 : 0;
1802
1803 //Custom / Script
1804 case MSF_SCRIPT1:
1805 return (m->flags8&1) ? 1 : 0;
1806 case MSF_SCRIPT2:
1807 return (m->flags8&2) ? 1 : 0;
1808 case MSF_SCRIPT3:
1809 return (m->flags8&4) ? 1 : 0;
1810 case MSF_SCRIPT4:
1811 return (m->flags8&8) ? 1 : 0;
1812 case MSF_SCRIPT5:
1813 return (m->flags8&16) ? 1 : 0;
1814
1815 //This is a dummy proc, but may have been used at one point in older versions.
1816 case MSF_DUMMY_8:
1817 return (m->flags&8) ? 1 : 0;
1818
1819
1820 default:
1821 {
1822 Z_scripterrlog("Illegal flag value (%d) passed to GetMapscreenFlag", flagid);
1823 return -1;
1824 }
1825 }
1826 }
1827 */
1828 //ScriptHelper
1829 class SH
1830 {
1831
1832 ///-----------------------------//
1833 // Errors //
1834 ///-----------------------------//
1835
1836 public:
1837
1838 enum __Error
1839 {
1840 _NoError, //OK!
1841 _Overflow, //script array too small
1842 _InvalidPointer, //passed NULL pointer or similar
1843 _OutOfBounds, //library array out of bounds
1844 _InvalidSpriteUID //bad npc, ffc, etc.
1845 };
1846
1847 #define INVALIDARRAY localRAM[0] //localRAM[0] is never used
1848
1849 //only if the player is messing with their pointers...
1850 static ZScriptArray& InvalidError(const int32_t ptr)
1851 {
1852 Z_scripterrlog("Invalid pointer (%i) passed to array (don't change the values of your array pointers)\n", ptr);
1853 return INVALIDARRAY;
1854 }
1855
1856 static void write_stack(const uint32_t stackoffset, const int32_t value)
1857 {
1858 if(stackoffset >= MAX_SCRIPT_REGISTERS)
1859 {
1860 Z_scripterrlog("Stack over or underflow, stack pointer = %ld\n", stackoffset);
1861 return;
1862 }
1863
1864 (*stack)[stackoffset] = value;
1865 }
1866
1867 305249220 static int32_t read_stack(const uint32_t stackoffset)
1868 {
1869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305249220 times.
305249220 if(stackoffset >= MAX_SCRIPT_REGISTERS)
1870 {
1871 Z_scripterrlog("Stack over or underflow, stack pointer = %ld\n", stackoffset);
1872 return -10000;
1873 }
1874
1875 305249220 return (*stack)[stackoffset];
1876 305249220 }
1877
1878 389494421 static INLINE int32_t get_arg(int32_t arg, bool v)
1879 {
1880
2/2
✓ Branch 0 taken 67778224 times.
✓ Branch 1 taken 321716197 times.
389494421 return v ? arg : get_register(arg);
1881 }
1882 };
1883
1884 ///----------------------------//
1885 // Misc. //
1886 ///----------------------------//
1887
1888 //Miscellaneous Helper
1889 class MiscH : public SH
1890 {
1891 public:
1892
1893 };
1894
1895 byte flagpos;
1896 int32_t flagval;
1897 11837609 void clear_ornextflag()
1898 {
1899 11837609 flagpos = 0;
1900 11837609 flagval = 0;
1901 11837609 }
1902 77405492 void ornextflag(bool flag)
1903 {
1904
2/2
✓ Branch 0 taken 75938961 times.
✓ Branch 1 taken 1466531 times.
77405492 if(flag) flagval |= 1<<flagpos;
1905 77405492 ++flagpos;
1906 77405492 }
1907
1908 6641017 int32_t get_screenflags(mapscr *m, int32_t flagset)
1909 {
1910 6641017 clear_ornextflag();
1911
1912
3/11
✓ Branch 0 taken 3734897 times.
✓ Branch 1 taken 2816511 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 89609 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
6641017 switch(flagset)
1913 {
1914 case 0: // Room Type
1915 3734897 ornextflag(m->flags6&1);
1916 3734897 ornextflag(m->flags6&2);
1917 3734897 ornextflag(m->flags7&8);
1918 3734897 break;
1919
1920 case 1: // View
1921 2816511 ornextflag(m->flags3&8);
1922 2816511 ornextflag(m->flags7&16);
1923 2816511 ornextflag(m->flags3&16);
1924 2816511 ornextflag(m->flags3&64);
1925 2816511 ornextflag(m->flags7&2);
1926 2816511 ornextflag(m->flags7&1);
1927 2816511 ornextflag(m->flags&fDARK);
1928 2816511 ornextflag(m->flags9&fDARK_DITHER);
1929 2816511 ornextflag(m->flags9&fDARK_TRANS);
1930 2816511 break;
1931
1932 case 2: // Secrets
1933 ornextflag(m->flags&1);
1934 ornextflag(m->flags5&16);
1935 ornextflag(m->flags6&4);
1936 ornextflag(m->flags6&32);
1937 break;
1938
1939 case 3: // Warp
1940 ornextflag(m->flags5&4);
1941 ornextflag(m->flags5&8);
1942 ornextflag(m->flags&64);
1943 ornextflag(m->flags8&64);
1944 ornextflag(m->flags3&32);
1945 ornextflag(m->flags9&fDISABLE_MIRROR);
1946 break;
1947
1948 case 4: // Item
1949 ornextflag(m->flags3&1);
1950 ornextflag(m->flags7&4);
1951 ornextflag(m->flags8&0x40);
1952 ornextflag(m->flags8&0x80);
1953 ornextflag(m->flags9&0x01);
1954 ornextflag(m->flags9&0x02);
1955 ornextflag(m->flags9&0x04);
1956 break;
1957
1958 case 5: // Combo
1959 ornextflag((m->flags2>>4)&2);
1960 ornextflag(m->flags3&2);
1961 ornextflag(m->flags5&2);
1962 ornextflag(m->flags6&64);
1963 break;
1964
1965 case 6: // Save
1966 ornextflag(m->flags4&64);
1967 ornextflag(m->flags4&128);
1968 ornextflag(m->flags6&8);
1969 ornextflag(m->flags6&16);
1970 break;
1971
1972 case 7: // FFC
1973 ornextflag(m->flags6&128);
1974 ornextflag(m->flags5&128);
1975 break;
1976
1977 case 8: // Whistle
1978 ornextflag(m->flags&16);
1979 ornextflag(m->flags7&64);
1980 ornextflag(m->flags7&128);
1981 break;
1982
1983 case 9: // Misc
1984 89609 ornextflag(m->flags&32);
1985 89609 ornextflag(m->flags5&64);
1986 89609 flagval |= m->flags8<<2;
1987 89609 break;
1988 }
1989
1990 6641017 return flagval*10000;
1991 }
1992
1993 1524086 int32_t get_screeneflags(mapscr *m, int32_t flagset)
1994 {
1995 1524086 clear_ornextflag();
1996
1997
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1524086 times.
✗ Branch 3 not taken.
1524086 switch(flagset)
1998 {
1999 case 0:
2000 flagval |= m->enemyflags&0x1F;
2001 break;
2002
2003 case 1:
2004 1524086 ornextflag(m->enemyflags&32);
2005 1524086 ornextflag(m->enemyflags&64);
2006 1524086 ornextflag(m->flags3&4);
2007 1524086 ornextflag(m->enemyflags&128);
2008 1524086 ornextflag((m->flags2>>4)&4);
2009 1524086 break;
2010
2011 case 2:
2012 ornextflag(m->flags3&128);
2013 ornextflag(m->flags&2);
2014 ornextflag((m->flags2>>4)&8);
2015 ornextflag(m->flags4&16);
2016 ornextflag(m->flags9&fENEMY_WAVES);
2017 break;
2018 }
2019
2020 1524086 return flagval*10000;
2021 }
2022
2023 1218351 int32_t get_mi(int32_t ref = MAPSCR_TEMP0)
2024 {
2025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1218351 times.
1218351 if(ref >= 0)
2026 {
2027 if(ref%MAPSCRS >= MAPSCRSNORMAL) return -1;
2028 return ref - (8*(ref / MAPSCRS));
2029 }
2030
1/3
✓ Branch 0 taken 1218351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1218351 switch(ref)
2031 {
2032 case MAPSCR_TEMP0: case MAPSCR_TEMP1: case MAPSCR_TEMP2: case MAPSCR_TEMP3:
2033 case MAPSCR_TEMP4: case MAPSCR_TEMP5: case MAPSCR_TEMP6:
2034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1218351 times.
1218351 if(homescr >= MAPSCRSNORMAL) return -1;
2035 1218351 return (currmap*MAPSCRSNORMAL)+homescr;
2036 case MAPSCR_SCROLL0: case MAPSCR_SCROLL1: case MAPSCR_SCROLL2: case MAPSCR_SCROLL3:
2037 case MAPSCR_SCROLL4: case MAPSCR_SCROLL5: case MAPSCR_SCROLL6:
2038 if(scrolling_scr >= MAPSCRSNORMAL) return -1;
2039 return (scrolling_map*MAPSCRSNORMAL)+scrolling_scr;
2040 }
2041 return -1;
2042 1218351 }
2043
2044 int32_t get_total_mi(int32_t ref = MAPSCR_TEMP0)
2045 {
2046 if(ref >= 0)
2047 return ref;
2048 switch(ref)
2049 {
2050 case MAPSCR_TEMP0: case MAPSCR_TEMP1: case MAPSCR_TEMP2: case MAPSCR_TEMP3:
2051 case MAPSCR_TEMP4: case MAPSCR_TEMP5: case MAPSCR_TEMP6:
2052 return (currmap*MAPSCRS)+currscr;
2053 case MAPSCR_SCROLL0: case MAPSCR_SCROLL1: case MAPSCR_SCROLL2: case MAPSCR_SCROLL3:
2054 case MAPSCR_SCROLL4: case MAPSCR_SCROLL5: case MAPSCR_SCROLL6:
2055 return (scrolling_map*MAPSCRS)+scrolling_scr;
2056 }
2057 return -1;
2058 }
2059
2060 ///------------------------------------------------//
2061 // Bounds Checking Functions //
2062 ///------------------------------------------------//
2063
2064 //Bounds Checker
2065 class BC : public SH
2066 {
2067 public:
2068
2069 18740053 static INLINE int32_t checkMapID(const int32_t ID, const char * const str)
2070 {
2071 //return checkBounds(ID, 0, map_count-1, str);
2072
2/4
✓ Branch 0 taken 18740053 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18740053 times.
18740053 if(ID < 0 || ID > map_count-1)
2073 {
2074 Z_scripterrlog("Invalid value (%i) passed to '%s'\n", ID+1, str);
2075 return _OutOfBounds;
2076 }
2077
2078 18740053 return _NoError;
2079 18740053 }
2080
2081 2871655 static INLINE int32_t checkDMapID(const int32_t ID, const char * const str)
2082 {
2083 2871655 return checkBounds(ID, 0, MAXDMAPS-1, str);
2084 }
2085
2086 81861600 static INLINE int32_t checkComboPos(const int32_t pos, const char * const str)
2087 {
2088 81861600 return checkBoundsPos(pos, 0, 175, str);
2089 }
2090
2091 127665 static INLINE int32_t checkTile(const int32_t pos, const char * const str)
2092 {
2093 127665 return checkBounds(pos, 0, NEWMAXTILES-1, str);
2094 }
2095
2096 2564 static INLINE int32_t checkCombo(const int32_t pos, const char * const str)
2097 {
2098 2564 return checkBounds(pos, 0, MAXCOMBOS-1, str);
2099 }
2100
2101 6076 static INLINE int32_t checkMisc(const int32_t a, const char * const str)
2102 {
2103 6076 return checkBounds(a, 0, 15, str);
2104 }
2105
2106 13999164 static INLINE int32_t checkMisc32(const int32_t a, const char * const str)
2107 {
2108 13999164 return checkBounds(a, 0, 31, str);
2109 }
2110
2111 3839 static INLINE int32_t checkMessage(const int32_t ID, const char * const str)
2112 {
2113 3839 return checkBounds(ID, 0, msg_strings_size-1, str);
2114 }
2115
2116 static INLINE int32_t checkLayer(const int32_t layer, const char * const str)
2117 {
2118 return checkBounds(layer, 0, 6, str);
2119 }
2120
2121 503812260 static INLINE int32_t checkFFC(const int32_t ffc, const char * const str)
2122 {
2123 503812260 return checkBounds(ffc, 0, MAXFFCS-1, str);
2124 }
2125
2126 15644354 static INLINE int32_t checkGuyIndex(const int32_t index, const char * const str)
2127 {
2128 15644354 return checkBoundsOneIndexed(index, 0, guys.Count()-1, str);
2129 }
2130
2131 136832 static INLINE int32_t checkItemIndex(const int32_t index, const char * const str)
2132 {
2133 136832 return checkBoundsOneIndexed(index, 0, items.Count()-1, str);
2134 }
2135
2136 2753647 static INLINE int32_t checkEWeaponIndex(const int32_t index, const char * const str)
2137 {
2138 2753647 return checkBoundsOneIndexed(index, 0, Ewpns.Count()-1, str);
2139 }
2140
2141 1201098 static INLINE int32_t checkLWeaponIndex(const int32_t index, const char * const str)
2142 {
2143 1201098 return checkBoundsOneIndexed(index, 0, Lwpns.Count()-1, str);
2144 }
2145
2146 2363 static INLINE int32_t checkGuyID(const int32_t ID, const char * const str)
2147 {
2148 //return checkBounds(ID, 0, MAXGUYS-1, str); //Can't create NPC ID 0
2149 2363 return checkBounds(ID, 1, MAXGUYS-1, str);
2150 }
2151
2152 77157 static INLINE int32_t checkItemID(const int32_t ID, const char * const str)
2153 {
2154 77157 return checkBounds(ID, 0, MAXITEMS-1, str);
2155 }
2156
2157 209179 static INLINE int32_t checkWeaponID(const int32_t ID, const char * const str)
2158 {
2159 209179 return checkBounds(ID, 0, MAXWPNS-1, str);
2160 }
2161
2162 147223 static INLINE int32_t checkWeaponMiscSprite(const int32_t ID, const char * const str)
2163 {
2164 147223 return checkBounds(ID, 0, MAXWPNS-1, str);
2165 }
2166
2167 170875 static INLINE int32_t checkSFXID(const int32_t ID, const char * const str)
2168 {
2169 170875 return checkBounds(ID, 0, WAV_COUNT-1, str);
2170 }
2171
2172 558650779 static INLINE int32_t checkBounds(const int32_t n, const int32_t boundlow, const int32_t boundup, const char * const funcvar)
2173 {
2174
4/4
✓ Branch 0 taken 558650775 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 229 times.
✓ Branch 3 taken 558650546 times.
558650779 if(n < boundlow || n > boundup)
2175 {
2176 233 Z_scripterrlog("Invalid value (%i) passed to '%s'\n", n, funcvar);
2177 233 return _OutOfBounds;
2178 }
2179
2180 558650546 return _NoError;
2181 558650779 }
2182
2183 81861600 static INLINE int32_t checkBoundsPos(const int32_t n, const int32_t boundlow, const int32_t boundup, const char * const funcvar)
2184 {
2185
3/4
✓ Branch 0 taken 81861600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1584 times.
✓ Branch 3 taken 81860016 times.
81861600 if(n < boundlow || n > boundup)
2186 {
2187 1584 Z_scripterrlog("Invalid position [%i] used to read to '%s'\n", n, funcvar);
2188 1584 return _OutOfBounds;
2189 }
2190
2191 81860016 return _NoError;
2192 81861600 }
2193
2194 19735931 static INLINE int32_t checkBoundsOneIndexed(const int32_t n, const int32_t boundlow, const int32_t boundup, const char * const funcvar)
2195 {
2196
4/4
✓ Branch 0 taken 19722168 times.
✓ Branch 1 taken 13763 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 19722094 times.
19735931 if(n < boundlow || n > boundup)
2197 {
2198 13837 Z_scripterrlog("Invalid value (%i) passed to '%s'\n", n+1, funcvar);
2199 13837 return _OutOfBounds;
2200 }
2201
2202 19722094 return _NoError;
2203 19735931 }
2204
2205 1634317806 static INLINE int32_t checkUserArrayIndex(const int32_t index, const dword size, const bool neg = false)
2206 {
2207
2208
6/6
✓ Branch 0 taken 40583137 times.
✓ Branch 1 taken 1593734669 times.
✓ Branch 2 taken 1633684725 times.
✓ Branch 3 taken 633081 times.
✓ Branch 4 taken 7038 times.
✓ Branch 5 taken 1633677687 times.
1634317806 if(index < (neg ? -int32_t(size) : 0) || index >= int32_t(size))
2209 {
2210 640119 Z_scripterrlog("Invalid index (%ld) to local array of size %ld\n", index, size);
2211 640119 return _OutOfBounds;
2212 }
2213
2214 1633677687 return _NoError;
2215 1634317806 }
2216 };
2217
2218 ///------------------------------------------------//
2219 // Pointer Handling Functions //
2220 ///------------------------------------------------//
2221 //MUST call AND check load functions before trying to use other functions
2222
2223
2224
2225
2226 //Guy Helper
2227 class GuyH : public SH
2228 {
2229
2230 public:
2231 78146347 static int32_t loadNPC(const int32_t eid, const char * const funcvar)
2232 {
2233
2/2
✓ Branch 0 taken 78146200 times.
✓ Branch 1 taken 147 times.
78146347 if ( !eid )
2234 {
2235 //can never be zero?
2236 147 Z_scripterrlog("The npc pointer used for %s is NULL or uninitialised.", funcvar);
2237 147 return _InvalidSpriteUID;
2238 }
2239 78146200 tempenemy = (enemy *) guys.getByUID(eid);
2240
2241
2/2
✓ Branch 0 taken 5901 times.
✓ Branch 1 taken 78140299 times.
78146200 if(tempenemy == NULL)
2242 {
2243 5901 Z_scripterrlog("Invalid NPC with UID %ld passed to %s\nNPCs on screen have UIDs ", eid, funcvar);
2244
2245
2/2
✓ Branch 0 taken 13743 times.
✓ Branch 1 taken 5901 times.
19644 for(word i = 0; i < guys.Count(); i++)
2246 13743 Z_scripterrlog("%ld ", guys.spr(i)->getUID());
2247
2248 5901 Z_scripterrlog("\n");
2249 5901 return _InvalidSpriteUID;
2250 }
2251
2252 78140299 return _NoError;
2253 78146347 }
2254
2255 73341958 static INLINE enemy *getNPC()
2256 {
2257 73341958 return tempenemy;
2258 }
2259
2260 // Currently only used in a context where the enemy is known to be valid,
2261 // so there's no need to print an error
2262 2 static int32_t getNPCIndex(const int32_t eid)
2263 {
2264
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 for(word i = 0; i < guys.Count(); i++)
2265 {
2266
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(guys.spr(i)->getUID() == eid)
2267 2 return i;
2268 }
2269
2270 return -1;
2271 2 }
2272
2273 6431345 static int32_t getNPCDMisc(const byte a)
2274 {
2275
12/33
✓ Branch 0 taken 2129 times.
✓ Branch 1 taken 9365 times.
✓ Branch 2 taken 1308 times.
✓ Branch 3 taken 5650 times.
✓ Branch 4 taken 874 times.
✓ Branch 5 taken 742 times.
✓ Branch 6 taken 107 times.
✓ Branch 7 taken 64 times.
✓ Branch 8 taken 391 times.
✓ Branch 9 taken 383 times.
✓ Branch 10 taken 3262601 times.
✓ Branch 11 taken 3147731 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
6431345 switch(a)
2276 {
2277 2129 case 0: return tempenemy->dmisc1;
2278 9365 case 1: return tempenemy->dmisc2;
2279 1308 case 2: return tempenemy->dmisc3;
2280 5650 case 3: return tempenemy->dmisc4;
2281 874 case 4: return tempenemy->dmisc5;
2282 742 case 5: return tempenemy->dmisc6;
2283 107 case 6: return tempenemy->dmisc7;
2284 64 case 7: return tempenemy->dmisc8;
2285 391 case 8: return tempenemy->dmisc9;
2286 383 case 9: return tempenemy->dmisc10;
2287 3262601 case 10: return tempenemy->dmisc11;
2288 3147731 case 11: return tempenemy->dmisc12;
2289 case 12: return tempenemy->dmisc13;
2290 case 13: return tempenemy->dmisc14;
2291 case 14: return tempenemy->dmisc15;
2292 case 15: return tempenemy->dmisc16;
2293 case 16: return tempenemy->dmisc17;
2294 case 17: return tempenemy->dmisc18;
2295 case 18: return tempenemy->dmisc19;
2296 case 19: return tempenemy->dmisc20;
2297 case 20: return tempenemy->dmisc21;
2298 case 21: return tempenemy->dmisc22;
2299 case 22: return tempenemy->dmisc23;
2300 case 23: return tempenemy->dmisc24;
2301 case 24: return tempenemy->dmisc25;
2302 case 25: return tempenemy->dmisc26;
2303 case 26: return tempenemy->dmisc27;
2304 case 27: return tempenemy->dmisc28;
2305 case 28: return tempenemy->dmisc29;
2306 case 29: return tempenemy->dmisc30;
2307 case 30: return tempenemy->dmisc31;
2308 case 31: return tempenemy->dmisc32;
2309 }
2310
2311 return 0;
2312 6431345 }
2313
2314 4023636 static bool hasHero()
2315 {
2316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4023636 times.
4023636 if(tempenemy->family == eeWALLM)
2317 return ((eWallM *) tempenemy)->hashero;
2318
2319
2/2
✓ Branch 0 taken 221194 times.
✓ Branch 1 taken 3802442 times.
4023636 if(tempenemy->family == eeWALK)
2320 221194 return ((eStalfos *) tempenemy)->hashero;
2321
2322 3802442 return false;
2323 4023636 }
2324
2325 3672506 static int32_t getMFlags()
2326 {
2327 3672506 clear_ornextflag();
2328 3672506 flagpos = 5;
2329 // Must be in the same order as in the Enemy Editor pane
2330 3672506 ornextflag(tempenemy->flags&(lens_only));
2331 3672506 ornextflag(tempenemy->flags2&(guy_flashing));
2332 3672506 ornextflag(tempenemy->flags2&(guy_blinking));
2333 3672506 ornextflag(tempenemy->flags2&(guy_transparent));
2334 3672506 ornextflag(tempenemy->flags&(inv_front));
2335 3672506 ornextflag(tempenemy->flags&(inv_left));
2336 3672506 ornextflag(tempenemy->flags&(inv_right));
2337 3672506 ornextflag(tempenemy->flags&(inv_back));
2338 3672506 ornextflag(tempenemy->flags&(guy_bkshield));
2339 3672506 return (tempenemy->flags&0x1F) | flagval;
2340 }
2341
2342 16354 static INLINE void clearTemp()
2343 {
2344 16354 tempenemy = NULL;
2345 16354 }
2346
2347 private:
2348
2349 static enemy *tempenemy;
2350 };
2351
2352 enemy *GuyH::tempenemy = NULL;
2353
2354 //Item Helper
2355 class ItemH : public SH
2356 {
2357
2358 public:
2359 static int32_t loadItem(const int32_t iid, const char * const funcvar)
2360 {
2361 if ( !iid )
2362 {
2363 //can never be zero?
2364 Z_scripterrlog("The item pointer used for %s is NULL or uninitialised.", funcvar);
2365 return _InvalidSpriteUID;
2366 }
2367
2368 tempitem = (item *) items.getByUID(iid);
2369
2370 if(tempitem == NULL)
2371 {
2372 Z_scripterrlog("Invalid item with UID %ld passed to %s\nItems on screen have UIDs ", iid, funcvar);
2373
2374 for(word i = 0; i < items.Count(); i++)
2375 Z_scripterrlog("%ld ", items.spr(i)->getUID());
2376
2377 Z_scripterrlog("\n");
2378 return _InvalidSpriteUID;
2379 }
2380
2381 return _NoError;
2382 }
2383
2384 2645 static int32_t getItemIndex(const int32_t iid)
2385 {
2386
1/2
✓ Branch 0 taken 3957 times.
✗ Branch 1 not taken.
3957 for(word i = 0; i < items.Count(); i++)
2387 {
2388
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 1312 times.
3957 if(items.spr(i)->getUID() == iid)
2389 2645 return i;
2390 1312 }
2391
2392 return -1;
2393 2645 }
2394
2395 static INLINE item* getItem()
2396 {
2397 return tempitem;
2398 }
2399
2400 16354 static INLINE void clearTemp()
2401 {
2402 16354 tempitem = NULL;
2403 16354 }
2404
2405 private:
2406
2407 static item *tempitem;
2408 };
2409
2410 item *ItemH::tempitem = NULL;
2411
2412 //LWeapon Helper
2413 class LwpnH : public SH
2414 {
2415
2416 public:
2417
2418
2419 static defWpnSprite getDefWeaponSprite(weapon *wp)
2420 {
2421 switch(wp->id)
2422 {
2423 case wNone: return ws_0;
2424 case wSword: return ws_0;
2425 case wBeam: return wsBeam;
2426 case wBrang : return wsBrang;
2427 case wBomb: return wsBomb;
2428 case wSBomb: return wsSBomb;
2429 case wLitBomb: return wsBombblast;
2430 case wLitSBomb: return wsBombblast;
2431 case wArrow: return wsArrow;
2432 case wFire: return wsFire;
2433 case wWhistle: return wsUnused45;
2434 case wBait: return wsBait;
2435 case wWand: return wsWandHandle;
2436 case wMagic: return wsMagic;
2437 case wCatching: return wsUnused45;
2438 case wWind: return wsWind;
2439 case wRefMagic: return wsRefMagic;
2440 case wRefFireball: return wsRefFireball;
2441 case wRefRock: return wsRock;
2442 case wHammer: return wsHammer;
2443 case wHookshot: return wsHookshotHead;
2444 case wHSHandle: return wsHookshotHandle;
2445 case wHSChain: return wsHookshotChainH;
2446 case wSSparkle: return wsSilverSparkle;
2447 case wFSparkle: return wsGoldSparkle;
2448 case wSmack: return wsHammerSmack;
2449 case wPhantom: return wsUnused45;
2450 case wCByrna: return wsByrnaCane;
2451 case wRefBeam: return wsRefBeam;
2452 case wStomp: return wsUnused45;
2453 case lwMax: return wsUnused45;
2454 case wScript1:
2455 case wScript2:
2456 case wScript3:
2457 case wScript4:
2458 case wScript5:
2459 case wScript6:
2460 case wScript7:
2461 case wScript8:
2462 case wScript9:
2463 case wScript10: return ws_0;
2464 case wIce: return wsIce; //new
2465 case wFlame: return wsEFire2; //new
2466 //not implemented; t/b/a
2467 case wSound:
2468 case wThrown:
2469 case wPot:
2470 case wLit:
2471 case wBombos:
2472 case wEther:
2473 case wQuake:
2474 case wSword180:
2475 case wSwordLA: return wsUnused45;
2476
2477 case ewFireball: return wsFireball2;
2478 case ewArrow: return wsEArrow;
2479 case ewBrang: return wsBrang;
2480 case ewSword: return wsEBeam;
2481 case ewRock: return wsRock;
2482 case ewMagic: return wsEMagic;
2483 case ewBomb: return wsEBomb;
2484 case ewSBomb: return wsESbomb;
2485 case ewLitBomb: return wsEBombblast;
2486 case ewLitSBomb: return wsESbombblast;
2487 case ewFireTrail: return wsEFiretrail;
2488 case ewFlame: return wsEFire;
2489 case ewWind: return wsEWind;
2490 case ewFlame2: return wsEFire2;
2491 case ewFlame2Trail: return wsEFiretrail2;
2492 case ewIce: return wsIce;
2493 case ewFireball2: return wsFireball2;
2494 default: return wsUnused45;
2495 }
2496 };
2497
2498 15079 static int32_t loadWeapon(const int32_t wid, const char * const funcvar)
2499 {
2500
1/2
✓ Branch 0 taken 15079 times.
✗ Branch 1 not taken.
15079 if ( !wid )
2501 {
2502 //can never be zero?
2503 Z_scripterrlog("The lweapon pointer used for %s is NULL or uninitialised.", funcvar);
2504 return _InvalidSpriteUID;
2505 }
2506 15079 tempweapon = (weapon *) Lwpns.getByUID(wid);
2507
2508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15079 times.
15079 if(tempweapon == NULL)
2509 {
2510 Z_scripterrlog("Invalid lweapon with UID %ld passed to %s\nLWeapons on screen have UIDs ", wid, funcvar);
2511
2512 for(word i = 0; i < Lwpns.Count(); i++)
2513 Z_scripterrlog("%ld ", Lwpns.spr(i)->getUID());
2514
2515 Z_scripterrlog("\n");
2516 return _InvalidSpriteUID;
2517 }
2518
2519 15079 return _NoError;
2520 15079 }
2521
2522 370531 static int32_t getLWeaponIndex(const int32_t lwid)
2523 {
2524
1/2
✓ Branch 0 taken 4133818 times.
✗ Branch 1 not taken.
4133818 for(word i = 0; i < Lwpns.Count(); i++)
2525 {
2526
2/2
✓ Branch 0 taken 370531 times.
✓ Branch 1 taken 3763287 times.
4133818 if(Lwpns.spr(i)->getUID() == lwid)
2527 370531 return i;
2528 3763287 }
2529
2530 return -1;
2531 370531 }
2532
2533 15079 static INLINE weapon *getWeapon()
2534 {
2535 15079 return tempweapon;
2536 }
2537
2538 16354 static INLINE void clearTemp()
2539 {
2540 16354 tempweapon = NULL;
2541 16354 }
2542
2543 private:
2544
2545 static weapon *tempweapon;
2546 };
2547
2548 weapon *LwpnH::tempweapon = NULL;
2549
2550 //EWeapon Helper
2551 class EwpnH : public SH
2552 {
2553
2554 public:
2555
2556 defWpnSprite getDefWeaponSprite(weapon *wp)
2557 {
2558 switch(wp->id)
2559 {
2560 case wNone: return ws_0;
2561 case wSword: return ws_0;
2562 case wBeam: return wsBeam;
2563 case wBrang : return wsBrang;
2564 case wBomb: return wsBomb;
2565 case wSBomb: return wsSBomb;
2566 case wLitBomb: return wsBombblast;
2567 case wLitSBomb: return wsBombblast;
2568 case wArrow: return wsArrow;
2569 case wFire: return wsFire;
2570 case wWhistle: return wsUnused45;
2571 case wBait: return wsBait;
2572 case wWand: return wsWandHandle;
2573 case wMagic: return wsMagic;
2574 case wCatching: return wsUnused45;
2575 case wWind: return wsWind;
2576 case wRefMagic: return wsRefMagic;
2577 case wRefFireball: return wsRefFireball;
2578 case wRefRock: return wsRock;
2579 case wHammer: return wsHammer;
2580 case wHookshot: return wsHookshotHead;
2581 case wHSHandle: return wsHookshotHandle;
2582 case wHSChain: return wsHookshotChainH;
2583 case wSSparkle: return wsSilverSparkle;
2584 case wFSparkle: return wsGoldSparkle;
2585 case wSmack: return wsHammerSmack;
2586 case wPhantom: return wsUnused45;
2587 case wCByrna: return wsByrnaCane;
2588 case wRefBeam: return wsRefBeam;
2589 case wStomp: return wsUnused45;
2590 case lwMax: return wsUnused45;
2591 case wScript1:
2592 case wScript2:
2593 case wScript3:
2594 case wScript4:
2595 case wScript5:
2596 case wScript6:
2597 case wScript7:
2598 case wScript8:
2599 case wScript9:
2600 case wScript10: return ws_0;
2601 case wIce: return wsIce; //new
2602 case wFlame: return wsEFire2; //new
2603 //not implemented; t/b/a
2604 case wSound:
2605 case wThrown:
2606 case wPot:
2607 case wLit:
2608 case wBombos:
2609 case wEther:
2610 case wQuake:
2611 case wSword180:
2612 case wSwordLA: return wsUnused45;
2613
2614 case ewFireball: return wsFireball2;
2615 case ewArrow: return wsEArrow;
2616 case ewBrang: return wsBrang;
2617 case ewSword: return wsEBeam;
2618 case ewRock: return wsRock;
2619 case ewMagic: return wsEMagic;
2620 case ewBomb: return wsEBomb;
2621 case ewSBomb: return wsESbomb;
2622 case ewLitBomb: return wsEBombblast;
2623 case ewLitSBomb: return wsESbombblast;
2624 case ewFireTrail: return wsEFiretrail;
2625 case ewFlame: return wsEFire;
2626 case ewWind: return wsEWind;
2627 case ewFlame2: return wsEFire2;
2628 case ewFlame2Trail: return wsEFiretrail2;
2629 case ewIce: return wsIce;
2630 case ewFireball2: return wsFireball2;
2631 default: return wsUnused45;
2632 }
2633 };
2634
2635 132144 static int32_t loadWeapon(const int32_t wid, const char * const funcvar)
2636 {
2637
1/2
✓ Branch 0 taken 132144 times.
✗ Branch 1 not taken.
132144 if ( !wid )
2638 {
2639 //can never be zero?
2640 Z_scripterrlog("The eweapon pointer used for %s is NULL or uninitialised.", funcvar);
2641 return _InvalidSpriteUID;
2642 }
2643 132144 tempweapon = (weapon *) Ewpns.getByUID(wid);
2644
2645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132144 times.
132144 if(tempweapon == NULL)
2646 {
2647 Z_scripterrlog("Invalid eweapon with UID %ld passed to %s\nEWeapons on screen have UIDs ", wid, funcvar);
2648
2649 for(word i = 0; i < Ewpns.Count(); i++)
2650 Z_scripterrlog("%ld ", Ewpns.spr(i)->getUID());
2651
2652 Z_scripterrlog("\n");
2653 return _InvalidSpriteUID;
2654 }
2655
2656 132144 return _NoError;
2657 132144 }
2658
2659 119542 static int32_t getEWeaponIndex(const int32_t ewid)
2660 {
2661
1/2
✓ Branch 0 taken 490280 times.
✗ Branch 1 not taken.
490280 for(word i = 0; i < Ewpns.Count(); i++)
2662 {
2663
2/2
✓ Branch 0 taken 119542 times.
✓ Branch 1 taken 370738 times.
490280 if(Ewpns.spr(i)->getUID() == ewid)
2664 119542 return i;
2665 370738 }
2666
2667 return -1;
2668 119542 }
2669
2670 132144 static INLINE weapon *getWeapon()
2671 {
2672 132144 return tempweapon;
2673 }
2674
2675 16354 static INLINE void clearTemp()
2676 {
2677 16354 tempweapon = NULL;
2678 16354 }
2679
2680 private:
2681
2682 static weapon *tempweapon;
2683 };
2684
2685 weapon *EwpnH::tempweapon = NULL;
2686
2687 16354 void clearScriptHelperData()
2688 {
2689 16354 GuyH::clearTemp();
2690 16354 ItemH::clearTemp();
2691 16354 LwpnH::clearTemp();
2692 16354 EwpnH::clearTemp();
2693 16354 }
2694
2695 ///---------------------------------------------//
2696 // Array Helper Functions //
2697 ///---------------------------------------------//
2698
2699 #define ZCARRAY_MAX_SIZE 214748
2700 class ArrayManager
2701 {
2702 public:
2703 ArrayManager(int32_t ptr, bool neg);
2704 ArrayManager(int32_t ptr);
2705
2706 int32_t get(int32_t indx) const;
2707 void set(int32_t indx, int32_t val);
2708 int32_t size() const;
2709
2710 bool resize(size_t newsize);
2711 bool resize_min(size_t minsz);
2712 bool can_resize();
2713 bool push(int32_t val, int indx = -1);
2714 int32_t pop(int indx = -1);
2715
2716 1959206 bool invalid() const {return _invalid;}
2717 bool internal() const {return !_invalid && !aptr;}
2718
2719 std::string asString(std::function<char const*(int32_t)> formatter, const size_t& limit) const;
2720
2721 bool negAccess;
2722 private:
2723 int32_t ptr;
2724 ZScriptArray* aptr;
2725 bool _invalid;
2726 };
2727
2728 //Array Helper
2729 class ArrayH : public SH
2730 {
2731 public:
2732 294114397 static size_t getSize(const int32_t ptr)
2733 {
2734 294114397 ArrayManager am(ptr);
2735 294114397 return am.size();
2736 }
2737
2738 //Can't you get the std::string and then check its length?
2739 static int32_t strlen(const int32_t ptr)
2740 {
2741 ArrayManager am(ptr);
2742 if (am.invalid() || am.size() == 0)
2743 return -1;
2744
2745 word count;
2746 size_t sz = am.size();
2747 for(count = 0; BC::checkUserArrayIndex(count, sz) == _NoError
2748 && am.get(count) != '\0'; count++);
2749
2750 return count;
2751 }
2752
2753 //Returns values of a zscript array as an std::string.
2754 1690174 static void getString(const int32_t ptr, string &str, dword num_chars = ZSCRIPT_MAX_STRING_CHARS, dword offset = 0)
2755 {
2756 1690174 ArrayManager am(ptr);
2757
2758
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1690169 times.
1690174 if(am.invalid())
2759 {
2760 5 str.clear();
2761 5 return;
2762 }
2763
2764 1690169 str.clear();
2765 1690169 size_t sz = am.size();
2766
5/6
✓ Branch 0 taken 19714764 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1690169 times.
✓ Branch 3 taken 18024595 times.
✓ Branch 4 taken 1690169 times.
✓ Branch 5 taken 18024595 times.
19714764 for(word i = offset; BC::checkUserArrayIndex(i, sz) == _NoError && am.get(i) != '\0' && num_chars != 0; i++)
2767 {
2768 18024595 int32_t c = am.get(i) / 10000;
2769
1/2
✓ Branch 0 taken 18024595 times.
✗ Branch 1 not taken.
18024595 if(char(c) != c)
2770 {
2771 Z_scripterrlog("Illegal char value (%d) at position [%d] in string pointer %d\n", c, i, ptr);
2772 Z_scripterrlog("Value of invalid char will overflow.\n");
2773 }
2774 18024595 str += char(c);
2775 18024595 --num_chars;
2776 18024595 }
2777 1690174 }
2778
2779 //Used for issues where reading the ZScript array floods the console with errors 'Accessing array index [12] size of 12.
2780 //Happens with Quad3D and some other functions, and I have no clue why. -Z ( 28th April, 2019 )
2781 //Like getString but for an array of longs instead of chars. *(arrayPtr is not checked for validity)
2782 static void getValues2(const int32_t ptr, int32_t* arrayPtr, dword num_values, dword offset = 0) //a hack -Z
2783 {
2784 ArrayManager am(ptr);
2785
2786 if(am.invalid())
2787 return;
2788
2789 size_t sz = am.size();
2790 for(word i = offset; BC::checkUserArrayIndex(i, sz+1) == _NoError && num_values != 0; i++)
2791 {
2792 arrayPtr[i] = (am.get(i) / 10000);
2793 num_values--;
2794 }
2795 }
2796
2797 //Like getString but for an array of longs instead of chars. *(arrayPtr is not checked for validity)
2798 static void getValues(const int32_t ptr, int32_t* arrayPtr, dword num_values, dword offset = 0)
2799 {
2800 ArrayManager am(ptr);
2801
2802 if (am.invalid())
2803 return;
2804 size_t sz = am.size();
2805 for(word i = offset; num_values != 0 && BC::checkUserArrayIndex(i, sz) == _NoError; i++)
2806 {
2807 arrayPtr[i] = (am.get(i) / 10000);
2808 num_values--;
2809 }
2810 }
2811
2812 static void copyValues(const int32_t ptr, const int32_t ptr2, size_t num_values)
2813 {
2814 ArrayManager am1(ptr), am2(ptr2);
2815 if(am1.invalid() || am2.invalid())
2816 return;
2817 size_t sz = std::min(am1.size(),am2.size());
2818 for(word i = 0; (BC::checkUserArrayIndex(i, sz) == _NoError) && num_values != 0; i++)
2819 {
2820 am1.set(i,am2.get(i));
2821 num_values--;
2822 }
2823 }
2824 //Get element from array
2825 1046668272 static INLINE int32_t getElement(const int32_t ptr, int32_t offset,
2826 const bool neg = false)
2827 {
2828 1046668272 ArrayManager am(ptr,neg);
2829 1046668272 return am.get(offset);
2830 }
2831
2832 //Set element in array
2833 518573504 static INLINE void setElement(const int32_t ptr, int32_t offset,
2834 const int32_t value, const bool neg = false)
2835 {
2836 518573504 ArrayManager am(ptr,neg);
2837 518573504 am.set(offset,value);
2838 518573504 }
2839
2840 //Puts values of a zscript array into a client <type> array. returns 0 on success. Overloaded
2841 template <typename T>
2842 static int32_t getArray(const int32_t ptr, T *refArray)
2843 {
2844 return getArray(ptr, getSize(ptr), 0, 0, 0, refArray);
2845 }
2846
2847 template <typename T>
2848 static int32_t getArray(const int32_t ptr, const word size, T *refArray)
2849 {
2850 return getArray(ptr, size, 0, 0, 0, refArray);
2851 }
2852
2853 template <typename T>
2854 static int32_t getArray(const int32_t ptr, const word size, word userOffset, const word userStride, const word refArrayOffset, T *refArray)
2855 {
2856 ArrayManager am(ptr);
2857
2858 if (am.invalid())
2859 return _InvalidPointer;
2860
2861 word j = 0, k = userStride;
2862
2863 size_t sz = am.size();
2864 for(word i = 0; j < size; i++)
2865 {
2866 if(i >= sz)
2867 return _Overflow;
2868
2869 if(userOffset-- > 0)
2870 continue;
2871
2872 if(k > 0)
2873 k--;
2874 else if(BC::checkUserArrayIndex(i, sz) == _NoError)
2875 {
2876 refArray[j + refArrayOffset] = T(am.get(i));
2877 k = userStride;
2878 j++;
2879 }
2880 }
2881
2882 return _NoError;
2883 }
2884
2885 250584 static int32_t setArray(const int32_t ptr, string const& s2, bool resize = false)
2886 {
2887 250584 ArrayManager am(ptr);
2888
2889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250584 times.
250584 if (am.invalid())
2890 return _InvalidPointer;
2891
2892 word i;
2893
2894
3/4
✓ Branch 0 taken 250584 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 243701 times.
✓ Branch 3 taken 6883 times.
250584 if(am.can_resize() && resize)
2895 6883 am.resize_min(s2.size()+1);
2896
2897 250584 size_t sz = am.size();
2898
2/2
✓ Branch 0 taken 5558866 times.
✓ Branch 1 taken 250536 times.
5809402 for(i = 0; i < s2.size(); i++)
2899 {
2900
2/2
✓ Branch 0 taken 5558818 times.
✓ Branch 1 taken 48 times.
5558866 if(i >= sz)
2901 {
2902 48 am.set(sz-1,'\0');
2903 48 return _Overflow;
2904 }
2905
2906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5558818 times.
5558818 if(BC::checkUserArrayIndex(i, sz) == _NoError)
2907 5558818 am.set(i,s2[i] * 10000);
2908 5558818 }
2909
2910
1/2
✓ Branch 0 taken 250536 times.
✗ Branch 1 not taken.
250536 if(BC::checkUserArrayIndex(i, sz) == _NoError)
2911 250536 am.set(i,'\0');
2912
2913 250536 return _NoError;
2914 250584 }
2915
2916 //Puts values of a client <type> array into a zscript array. returns 0 on success. Overloaded
2917 template <typename T>
2918 302 static int32_t setArray(const int32_t ptr, const word size, T *refArray, bool x10k = true, bool resize = false)
2919 {
2920 302 return setArray(ptr, size, 0, 0, 0, refArray, x10k, resize);
2921 }
2922
2923 template <typename T>
2924 302 static int32_t setArray(const int32_t ptr, const word size, word userOffset, const word userStride, const word refArrayOffset, T *refArray, bool x10k = true, bool resize = false)
2925 {
2926 302 ArrayManager am(ptr);
2927
2928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 302 times.
302 if (am.invalid())
2929 return _InvalidPointer;
2930
2931
2/4
✓ Branch 0 taken 302 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
302 if(am.can_resize() && resize)
2932 am.resize_min((userStride+1)*size);
2933
2934 302 word j = 0, k = userStride;
2935 302 size_t sz = am.size();
2936
2/2
✓ Branch 0 taken 1594 times.
✓ Branch 1 taken 302 times.
1896 for(word i = 0; j < size; i++)
2937 {
2938
1/2
✓ Branch 0 taken 1594 times.
✗ Branch 1 not taken.
1594 if(i >= sz)
2939 return _Overflow; //Resize?
2940
2941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1594 times.
1594 if (userOffset > 0)
2942 {
2943 --userOffset;
2944 continue;
2945 }
2946
2947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1594 times.
1594 if(k > 0)
2948 k--;
2949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1594 times.
1594 else if(BC::checkUserArrayIndex(i, sz) == _NoError)
2950 {
2951 1594 am.set(i,int32_t(refArray[j + refArrayOffset]) * (x10k ? 10000 : 1));
2952 1594 k = userStride;
2953 1594 j++;
2954 1594 }
2955 1594 }
2956
2957 302 return _NoError;
2958 302 }
2959 };
2960
2961 1861315379 ArrayManager::ArrayManager(int32_t ptr, bool neg) : negAccess(neg), ptr(ptr)
2962 {
2963 1861315379 _invalid = false;
2964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1861315379 times.
1861315379 if(ptr >= INTARR_OFFS)
2965 {
2966 aptr = nullptr;
2967 if(sz_int_arr(ptr) < 0)
2968 _invalid = true;
2969 }
2970
2/2
✓ Branch 0 taken 1861314736 times.
✓ Branch 1 taken 643 times.
1861315379 else if(ptr == 0)
2971 {
2972 643 aptr = &INVALIDARRAY;
2973 643 _invalid = true;
2974 643 }
2975
1/2
✓ Branch 0 taken 1861314736 times.
✗ Branch 1 not taken.
1861314736 else if(ptr < 0) //An object array?
2976 {
2977 int32_t objptr = -ptr;
2978 auto it = objectRAM.find(objptr);
2979 if(it == objectRAM.end())
2980 {
2981 aptr = &INVALIDARRAY;
2982 _invalid = true;
2983 }
2984 else aptr = &(it->second);
2985 }
2986
2/2
✓ Branch 0 taken 1600989601 times.
✓ Branch 1 taken 260325135 times.
1861314736 else if(ptr >= NUM_ZSCRIPT_ARRAYS) //Then it's a global
2987 {
2988 1600989601 dword gptr = ptr - NUM_ZSCRIPT_ARRAYS;
2989
2990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1600989601 times.
1600989601 if(gptr > game->globalRAM.size())
2991 {
2992 aptr = &INVALIDARRAY;
2993 _invalid = true;
2994 }
2995 1600989601 else aptr = &(game->globalRAM[gptr]);
2996 1600989601 }
2997 else
2998 {
2999
1/2
✓ Branch 0 taken 260325135 times.
✗ Branch 1 not taken.
260325135 if(!localRAM[ptr].Valid())
3000 {
3001 aptr = &INVALIDARRAY;
3002 _invalid = true;
3003 }
3004 260325135 else aptr = &(localRAM[ptr]);
3005 }
3006
2/2
✓ Branch 0 taken 1861314736 times.
✓ Branch 1 taken 643 times.
1861315379 if(_invalid)
3007 {
3008 643 Z_scripterrlog("Invalid pointer (%i) passed to array "
3009 643 "(don't change the values of your array pointers)\n", ptr);
3010 643 }
3011 1861315379 }
3012 296073603 ArrayManager::ArrayManager(int32_t ptr) : ArrayManager(ptr,can_neg_array){}
3013
3014 1084407759 int32_t ArrayManager::get(int32_t indx) const
3015 {
3016
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 1084407594 times.
1084407759 if(_invalid) return -10000;
3017 1084407594 int32_t sz = size();
3018
1/2
✓ Branch 0 taken 1084407594 times.
✗ Branch 1 not taken.
1084407594 if(aptr)
3019 {
3020
2/2
✓ Branch 0 taken 1083774180 times.
✓ Branch 1 taken 633414 times.
1084407594 if(BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
3021 {
3022
1/2
✓ Branch 0 taken 1083774180 times.
✗ Branch 1 not taken.
1083774180 if(indx < 0)
3023 indx += sz; //[-1] becomes [size-1] -Em
3024 1083774180 return (*aptr)[indx];
3025 }
3026 633414 }
3027 else //internal special array
3028 {
3029 if(sz >= 0 && BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
3030 {
3031 if(indx < 0)
3032 indx += sz; //[-1] becomes [size-1] -Em
3033 return get_int_arr(ptr, indx);
3034 }
3035 }
3036 633414 return -10000;
3037 1084407759 }
3038 524384500 void ArrayManager::set(int32_t indx, int32_t val)
3039 {
3040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 524384500 times.
524384500 if(_invalid) return;
3041 524384500 int32_t sz = size();
3042
1/2
✓ Branch 0 taken 524384500 times.
✗ Branch 1 not taken.
524384500 if(aptr)
3043 {
3044
2/2
✓ Branch 0 taken 524377795 times.
✓ Branch 1 taken 6705 times.
524384500 if(BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
3045 {
3046
1/2
✓ Branch 0 taken 524377795 times.
✗ Branch 1 not taken.
524377795 if(indx < 0)
3047 indx += sz; //[-1] becomes [size-1] -Em
3048 524377795 (*aptr)[indx] = val;
3049 524377795 }
3050 524384500 }
3051 else //internal special array
3052 {
3053 if(sz >= 0 && BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
3054 {
3055 if(indx < 0)
3056 indx += sz; //[-1] becomes [size-1] -Em
3057 set_int_arr(ptr, indx, val);
3058 }
3059 }
3060 524384500 }
3061 1904854445 int32_t ArrayManager::size() const
3062 {
3063
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 1904853972 times.
1904854445 if(_invalid) return -1;
3064
1/2
✓ Branch 0 taken 1904853972 times.
✗ Branch 1 not taken.
1904853972 if(aptr)
3065 1904853972 return aptr->Size();
3066 else // Internal special
3067 {
3068 int32_t sz = sz_int_arr(ptr);
3069 if(sz < 0)
3070 return -1;
3071 return sz;
3072 }
3073 1904854445 }
3074
3075 bool ArrayManager::resize(size_t newsize)
3076 {
3077 if(_invalid) return false;
3078 if(!aptr)
3079 {
3080 Z_scripterrlog("Special internal array '%d' not valid for operation 'Resize'\n", ptr);
3081 return false;
3082 }
3083 aptr->Resize(newsize);
3084 return true;
3085 }
3086 6883 bool ArrayManager::resize_min(size_t newsize)
3087 {
3088
1/2
✓ Branch 0 taken 6883 times.
✗ Branch 1 not taken.
6883 if(size() >= newsize)
3089 6883 return true;
3090 return resize(newsize);
3091 6883 }
3092 250886 bool ArrayManager::can_resize()
3093 {
3094
2/4
✓ Branch 0 taken 250886 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 250886 times.
✗ Branch 3 not taken.
250886 if(_invalid || !aptr)
3095 return false;
3096 250886 return true;
3097 250886 }
3098
3099 bool ArrayManager::push(int32_t val, int indx)
3100 {
3101 if(_invalid) return false;
3102 if(!aptr)
3103 {
3104 Z_scripterrlog("Special internal array '%d' not valid for operation 'Push'\n", ptr);
3105 return false;
3106 }
3107 if(aptr->Size() == ZCARRAY_MAX_SIZE)
3108 return false;
3109 aptr->Push(val,indx);
3110 return true;
3111 }
3112 int32_t ArrayManager::pop(int indx)
3113 {
3114 if(_invalid) return -10000;
3115 if(!aptr)
3116 {
3117 Z_scripterrlog("Special internal array '%d' not valid for operation 'Push'\n", ptr);
3118 return -10000;
3119 }
3120 if(aptr->Empty())
3121 {
3122 Z_scripterrlog("Array %d had nothing to Pop!\n",ptr);
3123 return -10000;
3124 }
3125 return aptr->Pop(indx);
3126 }
3127
3128 std::string ArrayManager::asString(std::function<char const*(int32_t)> formatter, const size_t& limit) const
3129 {
3130 if(_invalid) return "{ INVALID ARRAY }";
3131 std::ostringstream oss;
3132 oss << "{ ";
3133 size_t s = size();
3134 bool overflow = limit < s;
3135 if(overflow)
3136 s = limit;
3137
3138 for(auto q = 0; q < s; ++q)
3139 {
3140 oss << formatter(get(q));
3141 if (q + 1 < s)
3142 oss << ", ";
3143 }
3144 if (overflow)
3145 oss << ", ...";
3146 oss << " }";
3147 return oss.str();
3148 }
3149
3150 // Called to deallocate arrays when a script stops running
3151 24490 void deallocateArray(const int32_t ptrval)
3152 {
3153
1/2
✓ Branch 0 taken 24490 times.
✗ Branch 1 not taken.
24490 if(ptrval == 0) return;
3154
2/4
✓ Branch 0 taken 24490 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24490 times.
24490 if(ptrval==0 || ptrval >= NUM_ZSCRIPT_ARRAYS)
3155 Z_scripterrlog("Script tried to deallocate memory at invalid address %ld\n", ptrval);
3156
1/2
✓ Branch 0 taken 24490 times.
✗ Branch 1 not taken.
24490 else if(ptrval<0)
3157 Z_scripterrlog("Script tried to deallocate memory at object-based address %ld\n", ptrval);
3158 else
3159 {
3160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24490 times.
24490 if(arrayOwner[ptrval].specOwned) return; //ignore this deallocation
3161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24490 times.
24490 if(arrayOwner[ptrval].specCleared) return;
3162 24490 arrayOwner[ptrval].clear();
3163
3164
1/2
✓ Branch 0 taken 24490 times.
✗ Branch 1 not taken.
24490 if(!localRAM[ptrval].Valid())
3165 Z_scripterrlog("Script tried to deallocate memory that was not allocated at address %ld\n", ptrval);
3166 else
3167 24490 localRAM[ptrval].Clear();
3168 }
3169 24490 }
3170
3171 2910358 void FFScript::deallocateAllScriptOwned(ScriptType scriptType, const int32_t UID, bool requireAlways)
3172 {
3173
2/2
✓ Branch 0 taken 724679142 times.
✓ Branch 1 taken 2910358 times.
727589500 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
3174 {
3175 724679142 scb.script_created_bitmaps[q].own_clear(scriptType, UID);
3176 724679142 }
3177
2/2
✓ Branch 0 taken 745051648 times.
✓ Branch 1 taken 2910358 times.
747962006 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
3178 {
3179 745051648 script_rngs[q].own_clear(scriptType, UID);
3180 745051648 }
3181
2/2
✓ Branch 0 taken 745051648 times.
✓ Branch 1 taken 2910358 times.
747962006 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
3182 {
3183 745051648 script_paldatas[q].own_clear(scriptType, UID);
3184 745051648 }
3185
2/2
✓ Branch 0 taken 745051648 times.
✓ Branch 1 taken 2910358 times.
747962006 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
3186 {
3187 745051648 script_files[q].own_clear(scriptType, UID);
3188 745051648 }
3189
2/2
✓ Branch 0 taken 745051648 times.
✓ Branch 1 taken 2910358 times.
747962006 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
3190 {
3191 745051648 script_dirs[q].own_clear(scriptType, UID);
3192 745051648 }
3193
2/2
✓ Branch 0 taken 745051648 times.
✓ Branch 1 taken 2910358 times.
747962006 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
3194 {
3195 745051648 script_stacks[q].own_clear(scriptType, UID);
3196 745051648 }
3197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2910358 times.
2910358 for(int32_t q = 0; q < max_valid_object; ++q)
3198 {
3199 script_objects[q].own_clear(scriptType, UID);
3200 }
3201
4/4
✓ Branch 0 taken 825126 times.
✓ Branch 1 taken 2085232 times.
✓ Branch 2 taken 202865 times.
✓ Branch 3 taken 622261 times.
2910358 if(requireAlways && !get_qr(qr_ALWAYS_DEALLOCATE_ARRAYS))
3202 {
3203 //Keep 2.50.2 behavior if QR unchecked.
3204
2/2
✓ Branch 0 taken 603612 times.
✓ Branch 1 taken 18649 times.
622261 switch(scriptType)
3205 {
3206 case ScriptType::FFC:
3207 case ScriptType::Item:
3208 case ScriptType::Global:
3209 18649 return;
3210 }
3211 603612 }
3212 //Z_eventlog("Attempting array deallocation from %s UID %d\n", script_types[scriptType], UID);
3213
2/2
✓ Branch 0 taken 2891709 times.
✓ Branch 1 taken 11841548355 times.
11844440064 for(int32_t i = 1; i < NUM_ZSCRIPT_ARRAYS; i++)
3214 {
3215
2/2
✓ Branch 0 taken 11841526835 times.
✓ Branch 1 taken 21520 times.
11841548355 if(arrayOwner[i].own_clear(scriptType,UID))
3216 21520 deallocateArray(i);
3217 11841548355 }
3218 2910358 }
3219
3220 104 void FFScript::deallocateAllScriptOwned()
3221 {
3222
2/2
✓ Branch 0 taken 25896 times.
✓ Branch 1 taken 104 times.
26000 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
3223 {
3224 25896 scb.script_created_bitmaps[q].own_clear_any();
3225 25896 }
3226
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
3227 {
3228 26624 script_rngs[q].own_clear_any();
3229 26624 }
3230
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
3231 {
3232 26624 script_paldatas[q].own_clear_any();
3233 26624 }
3234
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
3235 {
3236 26624 script_files[q].own_clear_any();
3237 26624 }
3238
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
3239 {
3240 26624 script_dirs[q].own_clear_any();
3241 26624 }
3242
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
3243 {
3244 26624 script_stacks[q].own_clear_any();
3245 26624 }
3246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 for(int32_t q = 0; q < max_valid_object; ++q)
3247 {
3248 script_objects[q].own_clear_any();
3249 }
3250 //No QR check here- always deallocate on quest exit.
3251
2/2
✓ Branch 0 taken 425880 times.
✓ Branch 1 taken 104 times.
425984 for(int32_t i = 1; i < NUM_ZSCRIPT_ARRAYS; i++)
3252 {
3253
2/2
✓ Branch 0 taken 425852 times.
✓ Branch 1 taken 28 times.
425880 if(localRAM[i].Valid())
3254 {
3255 // Unowned arrays are ALSO deallocated!
3256 28 arrayOwner[i].clear();
3257 28 deallocateArray(i);
3258 28 }
3259 425880 }
3260 104 }
3261
3262 287 void FFScript::deallocateAllScriptOwnedCont()
3263 {
3264
2/2
✓ Branch 0 taken 71463 times.
✓ Branch 1 taken 287 times.
71750 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
3265 {
3266 71463 scb.script_created_bitmaps[q].own_clear_cont();
3267 71463 }
3268
2/2
✓ Branch 0 taken 73472 times.
✓ Branch 1 taken 287 times.
73759 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
3269 {
3270 73472 script_rngs[q].own_clear_cont();
3271 73472 }
3272
2/2
✓ Branch 0 taken 73472 times.
✓ Branch 1 taken 287 times.
73759 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
3273 {
3274 73472 script_paldatas[q].own_clear_cont();
3275 73472 }
3276
2/2
✓ Branch 0 taken 73472 times.
✓ Branch 1 taken 287 times.
73759 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
3277 {
3278 73472 script_files[q].own_clear_cont();
3279 73472 }
3280
2/2
✓ Branch 0 taken 73472 times.
✓ Branch 1 taken 287 times.
73759 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
3281 {
3282 73472 script_dirs[q].own_clear_cont();
3283 73472 }
3284
2/2
✓ Branch 0 taken 73472 times.
✓ Branch 1 taken 287 times.
73759 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
3285 {
3286 73472 script_stacks[q].own_clear_cont();
3287 73472 }
3288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 for(int32_t q = 0; q < max_valid_object; ++q)
3289 {
3290 script_objects[q].own_clear_cont();
3291 }
3292 //No QR check here- always deallocate on quest exit.
3293
2/2
✓ Branch 0 taken 1175265 times.
✓ Branch 1 taken 287 times.
1175552 for(int32_t i = 1; i < NUM_ZSCRIPT_ARRAYS; i++)
3294 {
3295
2/2
✓ Branch 0 taken 1172323 times.
✓ Branch 1 taken 2942 times.
1175265 if(localRAM[i].Valid())
3296 {
3297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2942 times.
2942 if(arrayOwner[i].own_clear_cont())
3298 2942 deallocateArray(i);
3299 2942 }
3300 1175265 }
3301 287 }
3302
3303 409929 item *checkItem(int32_t iid)
3304 {
3305 409929 item *s = (item *)items.getByUID(iid);
3306
3307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409929 times.
409929 if(s == NULL)
3308 {
3309 Z_eventlog("Script attempted to reference a nonexistent item!\n");
3310 Z_eventlog("You were trying to reference an item with UID = %ld; Items on screen are UIDs ", iid);
3311
3312 for(int32_t i=0; i<items.Count(); i++)
3313 {
3314 Z_eventlog("%ld ", items.spr(i)->getUID());
3315 }
3316
3317 Z_eventlog("\n");
3318 return NULL;
3319 }
3320
3321 409929 return s;
3322 409929 }
3323
3324 10097911 weapon *checkLWpn(int32_t eid, const char *what)
3325 {
3326 10097911 weapon *s = (weapon *)Lwpns.getByUID(eid);
3327
2/2
✓ Branch 0 taken 9981466 times.
✓ Branch 1 taken 116445 times.
10097911 if(s == NULL) //check lifted weapon
3328 {
3329 116445 weapon* lw = Hero.lift_wpn;
3330
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116445 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
116445 if(lw && lw->getUID() == eid)
3331 s = lw;
3332 116445 }
3333
2/2
✓ Branch 0 taken 9981466 times.
✓ Branch 1 taken 116445 times.
10097911 if(s == NULL)
3334 {
3335
3336 116445 Z_eventlog("Script attempted to reference a nonexistent LWeapon!\n");
3337 116445 Z_eventlog("You were trying to reference the %s of an LWeapon with UID = %ld; LWeapons on screen are UIDs ", what, eid);
3338
3339
2/2
✓ Branch 0 taken 71278 times.
✓ Branch 1 taken 116445 times.
187723 for(int32_t i=0; i<Lwpns.Count(); i++)
3340 {
3341 71278 Z_eventlog("%ld ", Lwpns.spr(i)->getUID());
3342 71278 }
3343
3344 116445 Z_eventlog("\n");
3345 116445 return NULL;
3346 }
3347
3348 9981466 return s;
3349 10097911 }
3350
3351 23422487 weapon *checkEWpn(int32_t eid, const char *what)
3352 {
3353 23422487 weapon *s = (weapon *)Ewpns.getByUID(eid);
3354
3355
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 23422483 times.
23422487 if(s == NULL)
3356 {
3357
3358 4 Z_eventlog("Script attempted to reference a nonexistent EWeapon!\n");
3359 4 Z_eventlog("You were trying to reference the %s of an EWeapon with UID = %ld; EWeapons on screen are UIDs ", what, eid);
3360
3361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 for(int32_t i=0; i<Ewpns.Count(); i++)
3362 {
3363 Z_eventlog("%ld ", Ewpns.spr(i)->getUID());
3364 }
3365
3366 4 Z_eventlog("\n");
3367 4 return NULL;
3368 }
3369
3370 23422483 return s;
3371 23422487 }
3372
3373 286 user_file *checkFile(int32_t ref, const char *what, bool req_file = false, bool skipError = false)
3374 {
3375
3/4
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 284 times.
286 if(ref > 0 && ref <= MAX_USER_FILES)
3376 {
3377 284 user_file* f = &script_files[ref-1];
3378
1/2
✓ Branch 0 taken 284 times.
✗ Branch 1 not taken.
284 if(f->reserved)
3379 {
3380
3/4
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 280 times.
284 if(req_file && !f->file)
3381 {
3382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 if(skipError) return NULL;
3383 280 Z_scripterrlog("Script attempted to reference an invalid file!\n");
3384 280 Z_scripterrlog("File with UID = %ld does not have an open file connection!\n",ref);
3385 280 Z_scripterrlog("Use '->Open()' or '->Create()' to hook to a system file.\n");
3386 280 return NULL;
3387 }
3388 4 return f;
3389 }
3390 }
3391
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(skipError) return NULL;
3392 Z_scripterrlog("Script attempted to reference a nonexistent File!\n");
3393 if(what)
3394 Z_scripterrlog("You were trying to reference the '%s' of a File with UID = %ld\n", what, ref);
3395 else
3396 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3397 return NULL;
3398 286 }
3399
3400 user_object *checkObject(int32_t ref, bool skipError = false)
3401 {
3402 if(ref > 0 && ref < MAX_USER_OBJECTS)
3403 {
3404 user_object* obj = &script_objects[ref-1];
3405 if(obj->reserved)
3406 {
3407 return obj;
3408 }
3409 }
3410 if(skipError) return NULL;
3411 Z_scripterrlog("Script attempted to reference a nonexistent object!\n");
3412 Z_scripterrlog("You were trying to reference an object with UID = %ld\n", ref);
3413 return NULL;
3414 }
3415
3416 132 user_genscript *checkGenericScr(int32_t ref, const char *what)
3417 {
3418
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(ref < 1 || ref >= NUMSCRIPTSGENERIC)
3419 {
3420 Z_scripterrlog("Invalid gendata pointer access (%ld) for '->%s'\n", ref, what);
3421 return NULL;
3422 }
3423 132 return &user_scripts[ref];
3424 132 }
3425 extern portal mirror_portal;
3426 portal *checkPortal(int32_t ref, const char *what, bool skiperr = false)
3427 {
3428 if(ref == -1)
3429 return &mirror_portal;
3430 portal* p = (portal*)portals.getByUID(ref);
3431 if(!p)
3432 {
3433 if(!skiperr)
3434 Z_scripterrlog("Invalid portal pointer access (%ld) for '->%s'\n", ref, what);
3435 return nullptr;
3436 }
3437 return p;
3438 }
3439
3440 savedportal *checkSavedPortal(int32_t ref, const char* what, bool skiperr = false)
3441 {
3442 savedportal* sp = game->getSavedPortal(ref);
3443 if(!sp)
3444 {
3445 if(!skiperr)
3446 Z_scripterrlog("Invalid savedportal pointer access (%ld) for '->%s'\n", ref, what);
3447 return nullptr;
3448 }
3449 return sp;
3450 }
3451 int32_t getPortalFromSaved(savedportal* p)
3452 {
3453 if(p == &(game->saved_mirror_portal))
3454 return -1;
3455 portal* prtl = nullptr;
3456 portals.forEach([&](sprite& spr)
3457 {
3458 portal* tmp = (portal*)&spr;
3459 if(p->getUID() == tmp->saved_data)
3460 {
3461 prtl = tmp;
3462 return true;
3463 }
3464 return false;
3465 });
3466 return prtl ? prtl->getUID() : 0;
3467 }
3468
3469 user_dir *checkDir(int32_t ref, const char *what, bool skipError = false)
3470 {
3471 if(ref > 0 && ref <= MAX_USER_DIRS)
3472 {
3473 user_dir* dr = &script_dirs[ref-1];
3474 if(dr->reserved)
3475 {
3476 return dr;
3477 }
3478 }
3479 if(skipError) return NULL;
3480 Z_scripterrlog("Script attempted to reference a nonexistent Directory!\n");
3481 if(what)
3482 Z_scripterrlog("You were trying to reference the '%s' of a Directory with UID = %ld\n", what, ref);
3483 else
3484 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3485 return NULL;
3486 }
3487
3488 user_stack *checkStack(int32_t ref, const char *what, bool skipError = false)
3489 {
3490 if(ref > 0 && ref <= USERSTACK_MAX_SIZE)
3491 {
3492 user_stack* st = &script_stacks[ref-1];
3493 if(st->reserved)
3494 {
3495 return st;
3496 }
3497 }
3498 if(skipError) return NULL;
3499 Z_scripterrlog("Script attempted to reference a nonexistent Stack!\n");
3500 if(what)
3501 Z_scripterrlog("You were trying to reference the '%s' of a Stack with UID = %ld\n", what, ref);
3502 else
3503 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3504 return NULL;
3505 }
3506
3507 303330 user_rng *checkRNG(int32_t ref, const char *what, bool skipError = false)
3508 {
3509
3/4
✓ Branch 0 taken 1523 times.
✓ Branch 1 taken 301807 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1523 times.
303330 if(ref > 0 && ref <= MAX_USER_RNGS)
3510 {
3511 1523 user_rng* rng = &script_rngs[ref-1];
3512
1/2
✓ Branch 0 taken 1523 times.
✗ Branch 1 not taken.
1523 if(rng->reserved)
3513 {
3514 1523 return rng;
3515 }
3516 }
3517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 301807 times.
301807 else if(!ref) //A null RNG pointer is special-case, access engine rng.
3518 {
3519 301807 return &nulrng;
3520 }
3521 if(skipError) return NULL;
3522 Z_scripterrlog("Script attempted to reference a nonexistent RNG!\n");
3523 if(what)
3524 Z_scripterrlog("You were trying to reference the '%s' of a RNG with UID = %ld\n", what, ref);
3525 else
3526 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3527 return NULL;
3528 303330 }
3529
3530 user_paldata* checkPalData(int32_t ref, const char* what, bool skipError = false)
3531 {
3532 if (ref > 0 && ref <= MAX_USER_PALDATAS)
3533 {
3534 user_paldata* pd = &script_paldatas[ref - 1];
3535 if (pd->reserved)
3536 {
3537 return pd;
3538 }
3539 }
3540 if (skipError) return NULL;
3541 Z_scripterrlog("Script attempted to reference a nonexistent paldata!\n");
3542 if(what)
3543 Z_scripterrlog("You were trying to reference the '%s' of a paldata with UID = %ld\n", what, ref);
3544 else
3545 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3546 return NULL;
3547 }
3548
3549 bottletype *checkBottleData(int32_t ref, const char *what, bool skipError = false)
3550 {
3551 if(ref > 0 && ref <= 64)
3552 {
3553 return &QMisc.bottle_types[ref-1];
3554 }
3555 if(skipError) return NULL;
3556 Z_scripterrlog("Script attempted to reference a nonexistent BottleData!\n");
3557 Z_scripterrlog("You were trying to reference the '%s' of a BottleData with UID = %ld\n", what, ref);
3558 return NULL;
3559 }
3560
3561 bottleshoptype *checkBottleShopData(int32_t ref, const char *what, bool skipError = false)
3562 {
3563 if(ref > 0 && ref <= 256)
3564 {
3565 return &QMisc.bottle_shop_types[ref-1];
3566 }
3567 if(skipError) return NULL;
3568 Z_scripterrlog("Script attempted to reference a nonexistent BottleShopData!\n");
3569 Z_scripterrlog("You were trying to reference the '%s' of a BottleShopData with UID = %ld\n", what, ref);
3570 return NULL;
3571 }
3572
3573 631599 user_bitmap *checkBitmap(int32_t ref, const char *what, bool req_valid = false, bool skipError = false)
3574 {
3575 631599 int32_t ind = ref - 10;
3576
2/4
✓ Branch 0 taken 631599 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 631599 times.
631599 if(ind >= firstUserGeneratedBitmap && ind < MAX_USER_BITMAPS)
3577 {
3578 631599 user_bitmap* b = &(scb.script_created_bitmaps[ind]);
3579
1/2
✓ Branch 0 taken 631599 times.
✗ Branch 1 not taken.
631599 if(b->reserved())
3580 {
3581
3/4
✓ Branch 0 taken 604925 times.
✓ Branch 1 taken 26674 times.
✓ Branch 2 taken 604925 times.
✗ Branch 3 not taken.
631599 if(req_valid && !b->u_bmp)
3582 {
3583 if(skipError) return NULL;
3584 Z_scripterrlog("Script attempted to reference an invalid bitmap!\n");
3585 Z_scripterrlog("Bitmap with UID = %ld does not have a valid memory bitmap!\n",ref);
3586 Z_scripterrlog("Use '->Create()' to create a memory bitmap.\n");
3587 return NULL;
3588 }
3589 631599 return b;
3590 }
3591 }
3592 else
3593 {
3594 switch(ind)
3595 {
3596 case rtSCREEN:
3597 case rtBMP0:
3598 case rtBMP1:
3599 case rtBMP2:
3600 case rtBMP3:
3601 case rtBMP4:
3602 case rtBMP5:
3603 case rtBMP6:
3604 zprint2("Internal error: 'checkBitmap()' recieved ref pointing to system bitmap!\n");
3605 zprint2("Please report this as a bug!\n");
3606 break;
3607 }
3608 }
3609 if(skipError) return NULL;
3610 Z_scripterrlog("Script attempted to reference a nonexistent bitmap!\n");
3611 if(what)
3612 Z_scripterrlog("You were trying to reference the '%s' of a bitmap with UID = %ld\n", what, ref);
3613 else
3614 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3615 return NULL;
3616 631599 }
3617
3618 extern const std::string subscr_names[sstMAX];
3619 ZCSubscreen *checkSubData(int32_t ref, const char *what, int req_ty = -1)
3620 {
3621 auto [ptr,ty] = load_subdata(ref);
3622 if(ptr)
3623 {
3624 if(req_ty < 0 || req_ty == ty)
3625 return ptr;
3626 else
3627 {
3628 Z_scripterrlog("Wrong type of SubscreenData accessed! Expecting type '%s', but found '%s'\n",
3629 subscr_names[req_ty].c_str(), subscr_names[ty].c_str());
3630 }
3631 }
3632 else Z_scripterrlog("Script attempted to reference a nonexistent SubscreenData!\n");
3633
3634 Z_scripterrlog("You were trying to reference the '%s' of a SubscreenData with UID = %ld\n", what, ref);
3635 return NULL;
3636 }
3637 SubscrPage *checkSubPage(int32_t ref, const char *what, int req_ty = -1)
3638 {
3639 auto [ptr,ty] = load_subpage(ref);
3640 if(ptr)
3641 {
3642 if(req_ty < 0 || req_ty == ty)
3643 return ptr;
3644 else
3645 {
3646 Z_scripterrlog("Wrong type of Subscreen accessed! Expecting type '%s', but found '%s'\n",
3647 subscr_names[req_ty].c_str(), subscr_names[ty].c_str());
3648 }
3649 }
3650 else Z_scripterrlog("Script attempted to reference a nonexistent SubscreenPage!\n");
3651
3652 Z_scripterrlog("You were trying to reference the '%s' of a SubscreenPage with UID = %ld\n", what, ref);
3653 return NULL;
3654 }
3655 SubscrWidget *checkSubWidg(int32_t ref, const char *what, int req_widg_ty = -1, int req_sub_ty = -1)
3656 {
3657 auto [ptr,ty] = load_subwidg(ref);
3658 if(ptr)
3659 {
3660 if(req_sub_ty < 0 || req_sub_ty == ty)
3661 {
3662 if(req_widg_ty < 0 || req_widg_ty == ptr->getType())
3663 return ptr;
3664 else
3665 {
3666 auto listdata = GUI::ZCListData::subscr_widgets();
3667 Z_scripterrlog("Wrong type of SubscreenWidget accessed! Expecting type '%s', but found '%s'\n",
3668 listdata.findText(req_widg_ty).c_str(), listdata.findText(ptr->getType()).c_str());
3669 }
3670 }
3671 else
3672 {
3673 Z_scripterrlog("Wrong type of Subscreen accessed! Expecting subscreen type '%s', but found '%s'\n",
3674 subscr_names[req_sub_ty].c_str(), subscr_names[ty].c_str());
3675 }
3676 }
3677 else Z_scripterrlog("Script attempted to reference a nonexistent SubscreenWidget!\n");
3678
3679 Z_scripterrlog("You were trying to reference the '%s' of a SubscreenWidget with UID = %ld\n", what, ref);
3680 return NULL;
3681 }
3682
3683 void bad_subwidg_type(string const& name, bool func, byte type)
3684 {
3685 Z_scripterrlog("Widget type %d '%s' does not have a '%s' %s!\n",
3686 type, subwidg_internal_names[type].c_str(), name.c_str(),
3687 func ? "function" : "value");
3688 }
3689
3690 int32_t get_screen_d(int32_t index1, int32_t index2)
3691 {
3692 if(index2 < 0 || index2 > 7)
3693 {
3694 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
3695 return 0;
3696 }
3697
3698 return game->screen_d[index1][index2];
3699 }
3700
3701 void set_screen_d(int32_t index1, int32_t index2, int32_t val)
3702 {
3703 if(index2 < 0 || index2 > 7)
3704 {
3705 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
3706 return;
3707 }
3708
3709 game->screen_d[index1][index2] = val;
3710 }
3711
3712 // If scr is currently being used as a layer, return that layer no.
3713 39845144 int32_t whichlayer(int32_t scr)
3714 {
3715
2/2
✓ Branch 0 taken 198687540 times.
✓ Branch 1 taken 28204008 times.
226891548 for(int32_t i = 0; i < 6; i++)
3716 {
3717
2/2
✓ Branch 0 taken 11641136 times.
✓ Branch 1 taken 187046404 times.
198687540 if(scr == (tmpscr->layermap[i] - 1) * MAPSCRS + tmpscr->layerscreen[i])
3718 11641136 return i;
3719 187046404 }
3720
3721 28204008 return -1;
3722 39845144 }
3723
3724 sprite *s;
3725
3726 int32_t item_flag(int32_t flag)
3727 {
3728 if(unsigned(ri->idata) >= MAXITEMS)
3729 {
3730 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
3731 return 0;
3732 }
3733 return (itemsbuf[ri->idata].flags & flag) ? 10000 : 0;
3734 }
3735 void item_flag(int32_t flag, bool val)
3736 {
3737 if(unsigned(ri->idata) >= MAXITEMS)
3738 {
3739 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
3740 return;
3741 }
3742 SETFLAG(itemsbuf[ri->idata].flags, flag, val);
3743 }
3744
3745 //Forward decl
3746 int32_t do_msgheight(int32_t msg, char const* str);
3747 int32_t do_msgwidth(int32_t msg, char const* str);
3748 //
3749
3750 int32_t earlyretval = -1;
3751 2760742172 int32_t get_register(const int32_t arg)
3752 {
3753 2760742172 int32_t ret = 0;
3754
3755 //Macros
3756
3757 #define GET_SPRITEDATA_VAR_INT(member, str) \
3758 { \
3759 if(unsigned(ri->spritesref) > (MAXWPNS-1) ) \
3760 { \
3761 ret = -10000; \
3762 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", str, (ri->spritesref*10000));\
3763 } \
3764 else \
3765 ret = (wpnsbuf[ri->spritesref].member * 10000); \
3766 }
3767
3768
326/1411
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440400 times.
✓ Branch 4 taken 468471069 times.
✓ Branch 5 taken 1184834 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 8343962 times.
✓ Branch 8 taken 7892556 times.
✓ Branch 9 taken 35 times.
✓ Branch 10 taken 35 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 35 times.
✓ Branch 13 taken 35 times.
✓ Branch 14 taken 2180472 times.
✓ Branch 15 taken 103 times.
✓ Branch 16 taken 98 times.
✓ Branch 17 taken 2596310 times.
✓ Branch 18 taken 2596581 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 1282 times.
✓ Branch 21 taken 641181 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 756380 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 15444108 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 2112268 times.
✓ Branch 29 taken 655865 times.
✓ Branch 30 taken 552027 times.
✓ Branch 31 taken 44798253 times.
✓ Branch 32 taken 17 times.
✓ Branch 33 taken 19585851 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 5424 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 801725 times.
✓ Branch 38 taken 557644 times.
✓ Branch 39 taken 623338 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✓ Branch 43 taken 280566 times.
✓ Branch 44 taken 481556 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 6213788 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 206522 times.
✓ Branch 49 taken 206522 times.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✓ Branch 54 taken 206547 times.
✓ Branch 55 taken 206547 times.
✓ Branch 56 taken 173466 times.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✓ Branch 59 taken 4636 times.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✓ Branch 69 taken 2 times.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✓ Branch 72 taken 15348 times.
✓ Branch 73 taken 15551 times.
✓ Branch 74 taken 12319 times.
✓ Branch 75 taken 13864 times.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✓ Branch 83 taken 88721 times.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✓ Branch 104 taken 92884 times.
✓ Branch 105 taken 4123 times.
✓ Branch 106 taken 1334115 times.
✓ Branch 107 taken 847431 times.
✓ Branch 108 taken 1327379 times.
✓ Branch 109 taken 1369597 times.
✓ Branch 110 taken 5693944 times.
✓ Branch 111 taken 5182994 times.
✓ Branch 112 taken 3135646 times.
✓ Branch 113 taken 3131387 times.
✓ Branch 114 taken 119289 times.
✓ Branch 115 taken 119580 times.
✓ Branch 116 taken 23391 times.
✓ Branch 117 taken 23391 times.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✗ Branch 121 not taken.
✓ Branch 122 taken 766680 times.
✗ Branch 123 not taken.
✓ Branch 124 taken 1041016 times.
✓ Branch 125 taken 728101 times.
✓ Branch 126 taken 276546 times.
✓ Branch 127 taken 775420 times.
✓ Branch 128 taken 715403 times.
✓ Branch 129 taken 556980 times.
✓ Branch 130 taken 514803 times.
✓ Branch 131 taken 1875584 times.
✓ Branch 132 taken 1726419 times.
✓ Branch 133 taken 1861217 times.
✓ Branch 134 taken 1691656 times.
✓ Branch 135 taken 873882 times.
✓ Branch 136 taken 873847 times.
✓ Branch 137 taken 541201 times.
✓ Branch 138 taken 541201 times.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 144 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✓ Branch 148 taken 1121 times.
✓ Branch 149 taken 6213 times.
✗ Branch 150 not taken.
✗ Branch 151 not taken.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✗ Branch 154 not taken.
✓ Branch 155 taken 5848 times.
✗ Branch 156 not taken.
✓ Branch 157 taken 24 times.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✓ Branch 162 taken 4206 times.
✓ Branch 163 taken 5084 times.
✓ Branch 164 taken 114 times.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✗ Branch 167 not taken.
✓ Branch 168 taken 117090 times.
✓ Branch 169 taken 7933 times.
✗ Branch 170 not taken.
✗ Branch 171 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✗ Branch 174 not taken.
✓ Branch 175 taken 18 times.
✓ Branch 176 taken 7933 times.
✗ Branch 177 not taken.
✗ Branch 178 not taken.
✗ Branch 179 not taken.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 183 not taken.
✗ Branch 184 not taken.
✓ Branch 185 taken 2552 times.
✓ Branch 186 taken 2552 times.
✓ Branch 187 taken 6 times.
✓ Branch 188 taken 334 times.
✗ Branch 189 not taken.
✗ Branch 190 not taken.
✗ Branch 191 not taken.
✓ Branch 192 taken 2552 times.
✓ Branch 193 taken 2552 times.
✓ Branch 194 taken 2542 times.
✓ Branch 195 taken 1300 times.
✓ Branch 196 taken 1300 times.
✓ Branch 197 taken 685905 times.
✗ Branch 198 not taken.
✗ Branch 199 not taken.
✓ Branch 200 taken 19906 times.
✓ Branch 201 taken 108294 times.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✗ Branch 207 not taken.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✗ Branch 210 not taken.
✗ Branch 211 not taken.
✗ Branch 212 not taken.
✗ Branch 213 not taken.
✗ Branch 214 not taken.
✗ Branch 215 not taken.
✗ Branch 216 not taken.
✗ Branch 217 not taken.
✗ Branch 218 not taken.
✗ Branch 219 not taken.
✗ Branch 220 not taken.
✗ Branch 221 not taken.
✗ Branch 222 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✗ Branch 233 not taken.
✗ Branch 234 not taken.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✗ Branch 237 not taken.
✗ Branch 238 not taken.
✗ Branch 239 not taken.
✗ Branch 240 not taken.
✗ Branch 241 not taken.
✗ Branch 242 not taken.
✗ Branch 243 not taken.
✗ Branch 244 not taken.
✓ Branch 245 taken 713905 times.
✗ Branch 246 not taken.
✓ Branch 247 taken 709431 times.
✓ Branch 248 taken 55748 times.
✗ Branch 249 not taken.
✗ Branch 250 not taken.
✓ Branch 251 taken 67667 times.
✗ Branch 252 not taken.
✓ Branch 253 taken 1329 times.
✓ Branch 254 taken 2 times.
✗ Branch 255 not taken.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✗ Branch 258 not taken.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✗ Branch 261 not taken.
✓ Branch 262 taken 85830 times.
✓ Branch 263 taken 1122 times.
✓ Branch 264 taken 3785245 times.
✓ Branch 265 taken 49772 times.
✗ Branch 266 not taken.
✗ Branch 267 not taken.
✓ Branch 268 taken 49794 times.
✗ Branch 269 not taken.
✓ Branch 270 taken 3289 times.
✗ Branch 271 not taken.
✓ Branch 272 taken 3289 times.
✗ Branch 273 not taken.
✗ Branch 274 not taken.
✓ Branch 275 taken 1094820 times.
✗ Branch 276 not taken.
✓ Branch 277 taken 830567 times.
✗ Branch 278 not taken.
✓ Branch 279 taken 135142 times.
✓ Branch 280 taken 132394 times.
✗ Branch 281 not taken.
✗ Branch 282 not taken.
✗ Branch 283 not taken.
✗ Branch 284 not taken.
✗ Branch 285 not taken.
✗ Branch 286 not taken.
✓ Branch 287 taken 133136 times.
✓ Branch 288 taken 135091 times.
✓ Branch 289 taken 27874 times.
✓ Branch 290 taken 25249 times.
✓ Branch 291 taken 25249 times.
✓ Branch 292 taken 1553638 times.
✓ Branch 293 taken 4320 times.
✗ Branch 294 not taken.
✗ Branch 295 not taken.
✗ Branch 296 not taken.
✗ Branch 297 not taken.
✓ Branch 298 taken 179 times.
✗ Branch 299 not taken.
✓ Branch 300 taken 180 times.
✗ Branch 301 not taken.
✗ Branch 302 not taken.
✗ Branch 303 not taken.
✗ Branch 304 not taken.
✗ Branch 305 not taken.
✗ Branch 306 not taken.
✗ Branch 307 not taken.
✗ Branch 308 not taken.
✗ Branch 309 not taken.
✗ Branch 310 not taken.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✗ Branch 314 not taken.
✗ Branch 315 not taken.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✗ Branch 319 not taken.
✗ Branch 320 not taken.
✗ Branch 321 not taken.
✓ Branch 322 taken 1267145 times.
✗ Branch 323 not taken.
✓ Branch 324 taken 1266708 times.
✓ Branch 325 taken 63485 times.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✓ Branch 328 taken 22679 times.
✗ Branch 329 not taken.
✗ Branch 330 not taken.
✓ Branch 331 taken 362690 times.
✓ Branch 332 taken 373525 times.
✗ Branch 333 not taken.
✗ Branch 334 not taken.
✗ Branch 335 not taken.
✓ Branch 336 taken 68688 times.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✓ Branch 339 taken 46359 times.
✓ Branch 340 taken 90188 times.
✓ Branch 341 taken 154 times.
✓ Branch 342 taken 2150394 times.
✓ Branch 343 taken 106032 times.
✗ Branch 344 not taken.
✗ Branch 345 not taken.
✓ Branch 346 taken 24909 times.
✗ Branch 347 not taken.
✓ Branch 348 taken 70 times.
✗ Branch 349 not taken.
✓ Branch 350 taken 70 times.
✗ Branch 351 not taken.
✗ Branch 352 not taken.
✓ Branch 353 taken 1913328 times.
✗ Branch 354 not taken.
✓ Branch 355 taken 2925 times.
✗ Branch 356 not taken.
✓ Branch 357 taken 65540 times.
✓ Branch 358 taken 65540 times.
✓ Branch 359 taken 8 times.
✓ Branch 360 taken 96 times.
✗ Branch 361 not taken.
✗ Branch 362 not taken.
✗ Branch 363 not taken.
✗ Branch 364 not taken.
✓ Branch 365 taken 62523 times.
✓ Branch 366 taken 62523 times.
✓ Branch 367 taken 12470 times.
✓ Branch 368 taken 24497 times.
✓ Branch 369 taken 24497 times.
✓ Branch 370 taken 13780500 times.
✗ Branch 371 not taken.
✗ Branch 372 not taken.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
✗ Branch 376 not taken.
✓ Branch 377 taken 16680 times.
✗ Branch 378 not taken.
✗ Branch 379 not taken.
✗ Branch 380 not taken.
✗ Branch 381 not taken.
✗ Branch 382 not taken.
✗ Branch 383 not taken.
✗ Branch 384 not taken.
✗ Branch 385 not taken.
✗ Branch 386 not taken.
✗ Branch 387 not taken.
✗ Branch 388 not taken.
✗ Branch 389 not taken.
✗ Branch 390 not taken.
✗ Branch 391 not taken.
✗ Branch 392 not taken.
✗ Branch 393 not taken.
✗ Branch 394 not taken.
✗ Branch 395 not taken.
✗ Branch 396 not taken.
✗ Branch 397 not taken.
✗ Branch 398 not taken.
✗ Branch 399 not taken.
✗ Branch 400 not taken.
✗ Branch 401 not taken.
✗ Branch 402 not taken.
✗ Branch 403 not taken.
✗ Branch 404 not taken.
✗ Branch 405 not taken.
✗ Branch 406 not taken.
✗ Branch 407 not taken.
✗ Branch 408 not taken.
✗ Branch 409 not taken.
✗ Branch 410 not taken.
✗ Branch 411 not taken.
✗ Branch 412 not taken.
✗ Branch 413 not taken.
✗ Branch 414 not taken.
✗ Branch 415 not taken.
✓ Branch 416 taken 17 times.
✓ Branch 417 taken 26 times.
✓ Branch 418 taken 678 times.
✓ Branch 419 taken 972 times.
✓ Branch 420 taken 14 times.
✓ Branch 421 taken 471 times.
✓ Branch 422 taken 4013519 times.
✓ Branch 423 taken 1586472 times.
✓ Branch 424 taken 15 times.
✗ Branch 425 not taken.
✗ Branch 426 not taken.
✗ Branch 427 not taken.
✓ Branch 428 taken 2365308 times.
✗ Branch 429 not taken.
✓ Branch 430 taken 561132 times.
✗ Branch 431 not taken.
✗ Branch 432 not taken.
✗ Branch 433 not taken.
✓ Branch 434 taken 225833 times.
✗ Branch 435 not taken.
✗ Branch 436 not taken.
✗ Branch 437 not taken.
✗ Branch 438 not taken.
✓ Branch 439 taken 22550639 times.
✓ Branch 440 taken 14110188 times.
✓ Branch 441 taken 125 times.
✓ Branch 442 taken 63717 times.
✗ Branch 443 not taken.
✗ Branch 444 not taken.
✓ Branch 445 taken 49186486 times.
✓ Branch 446 taken 14019927 times.
✗ Branch 447 not taken.
✗ Branch 448 not taken.
✗ Branch 449 not taken.
✗ Branch 450 not taken.
✗ Branch 451 not taken.
✗ Branch 452 not taken.
✗ Branch 453 not taken.
✗ Branch 454 not taken.
✗ Branch 455 not taken.
✗ Branch 456 not taken.
✗ Branch 457 not taken.
✗ Branch 458 not taken.
✗ Branch 459 not taken.
✗ Branch 460 not taken.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✗ Branch 463 not taken.
✗ Branch 464 not taken.
✗ Branch 465 not taken.
✗ Branch 466 not taken.
✗ Branch 467 not taken.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✗ Branch 471 not taken.
✗ Branch 472 not taken.
✗ Branch 473 not taken.
✗ Branch 474 not taken.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✗ Branch 479 not taken.
✗ Branch 480 not taken.
✗ Branch 481 not taken.
✗ Branch 482 not taken.
✗ Branch 483 not taken.
✗ Branch 484 not taken.
✗ Branch 485 not taken.
✗ Branch 486 not taken.
✓ Branch 487 taken 109824 times.
✗ Branch 488 not taken.
✗ Branch 489 not taken.
✗ Branch 490 not taken.
✗ Branch 491 not taken.
✗ Branch 492 not taken.
✗ Branch 493 not taken.
✗ Branch 494 not taken.
✗ Branch 495 not taken.
✗ Branch 496 not taken.
✗ Branch 497 not taken.
✗ Branch 498 not taken.
✗ Branch 499 not taken.
✓ Branch 500 taken 1 times.
✗ Branch 501 not taken.
✗ Branch 502 not taken.
✓ Branch 503 taken 910 times.
✓ Branch 504 taken 43250 times.
✗ Branch 505 not taken.
✓ Branch 506 taken 3 times.
✓ Branch 507 taken 4 times.
✗ Branch 508 not taken.
✗ Branch 509 not taken.
✗ Branch 510 not taken.
✗ Branch 511 not taken.
✗ Branch 512 not taken.
✗ Branch 513 not taken.
✗ Branch 514 not taken.
✗ Branch 515 not taken.
✗ Branch 516 not taken.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✗ Branch 519 not taken.
✗ Branch 520 not taken.
✗ Branch 521 not taken.
✗ Branch 522 not taken.
✓ Branch 523 taken 10246 times.
✓ Branch 524 taken 7214 times.
✓ Branch 525 taken 2272 times.
✓ Branch 526 taken 6641017 times.
✓ Branch 527 taken 1524086 times.
✓ Branch 528 taken 11320291 times.
✗ Branch 529 not taken.
✗ Branch 530 not taken.
✗ Branch 531 not taken.
✗ Branch 532 not taken.
✓ Branch 533 taken 1 times.
✓ Branch 534 taken 1 times.
✗ Branch 535 not taken.
✗ Branch 536 not taken.
✗ Branch 537 not taken.
✗ Branch 538 not taken.
✗ Branch 539 not taken.
✗ Branch 540 not taken.
✗ Branch 541 not taken.
✗ Branch 542 not taken.
✓ Branch 543 taken 6509791 times.
✗ Branch 544 not taken.
✗ Branch 545 not taken.
✓ Branch 546 taken 146 times.
✗ Branch 547 not taken.
✗ Branch 548 not taken.
✗ Branch 549 not taken.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✗ Branch 552 not taken.
✗ Branch 553 not taken.
✗ Branch 554 not taken.
✗ Branch 555 not taken.
✓ Branch 556 taken 16 times.
✗ Branch 557 not taken.
✗ Branch 558 not taken.
✗ Branch 559 not taken.
✓ Branch 560 taken 734834 times.
✗ Branch 561 not taken.
✗ Branch 562 not taken.
✗ Branch 563 not taken.
✗ Branch 564 not taken.
✗ Branch 565 not taken.
✗ Branch 566 not taken.
✗ Branch 567 not taken.
✗ Branch 568 not taken.
✗ Branch 569 not taken.
✗ Branch 570 not taken.
✗ Branch 571 not taken.
✗ Branch 572 not taken.
✗ Branch 573 not taken.
✓ Branch 574 taken 22016 times.
✗ Branch 575 not taken.
✗ Branch 576 not taken.
✗ Branch 577 not taken.
✗ Branch 578 not taken.
✗ Branch 579 not taken.
✓ Branch 580 taken 10673 times.
✗ Branch 581 not taken.
✗ Branch 582 not taken.
✗ Branch 583 not taken.
✗ Branch 584 not taken.
✗ Branch 585 not taken.
✗ Branch 586 not taken.
✗ Branch 587 not taken.
✓ Branch 588 taken 15653 times.
✓ Branch 589 taken 158257 times.
✓ Branch 590 taken 56823 times.
✓ Branch 591 taken 1340206 times.
✓ Branch 592 taken 2886839 times.
✓ Branch 593 taken 15646729 times.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✓ Branch 596 taken 25786 times.
✗ Branch 597 not taken.
✗ Branch 598 not taken.
✗ Branch 599 not taken.
✓ Branch 600 taken 756919 times.
✗ Branch 601 not taken.
✗ Branch 602 not taken.
✗ Branch 603 not taken.
✗ Branch 604 not taken.
✗ Branch 605 not taken.
✗ Branch 606 not taken.
✓ Branch 607 taken 427 times.
✗ Branch 608 not taken.
✗ Branch 609 not taken.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 612 not taken.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✗ Branch 615 not taken.
✗ Branch 616 not taken.
✗ Branch 617 not taken.
✗ Branch 618 not taken.
✗ Branch 619 not taken.
✗ Branch 620 not taken.
✗ Branch 621 not taken.
✗ Branch 622 not taken.
✗ Branch 623 not taken.
✗ Branch 624 not taken.
✗ Branch 625 not taken.
✗ Branch 626 not taken.
✗ Branch 627 not taken.
✗ Branch 628 not taken.
✗ Branch 629 not taken.
✗ Branch 630 not taken.
✗ Branch 631 not taken.
✗ Branch 632 not taken.
✗ Branch 633 not taken.
✗ Branch 634 not taken.
✗ Branch 635 not taken.
✗ Branch 636 not taken.
✗ Branch 637 not taken.
✗ Branch 638 not taken.
✗ Branch 639 not taken.
✗ Branch 640 not taken.
✗ Branch 641 not taken.
✗ Branch 642 not taken.
✗ Branch 643 not taken.
✗ Branch 644 not taken.
✗ Branch 645 not taken.
✗ Branch 646 not taken.
✗ Branch 647 not taken.
✗ Branch 648 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✗ Branch 651 not taken.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✗ Branch 654 not taken.
✗ Branch 655 not taken.
✗ Branch 656 not taken.
✗ Branch 657 not taken.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✗ Branch 660 not taken.
✗ Branch 661 not taken.
✗ Branch 662 not taken.
✗ Branch 663 not taken.
✗ Branch 664 not taken.
✗ Branch 665 not taken.
✗ Branch 666 not taken.
✗ Branch 667 not taken.
✗ Branch 668 not taken.
✗ Branch 669 not taken.
✗ Branch 670 not taken.
✗ Branch 671 not taken.
✗ Branch 672 not taken.
✗ Branch 673 not taken.
✗ Branch 674 not taken.
✗ Branch 675 not taken.
✗ Branch 676 not taken.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✗ Branch 679 not taken.
✗ Branch 680 not taken.
✗ Branch 681 not taken.
✗ Branch 682 not taken.
✗ Branch 683 not taken.
✗ Branch 684 not taken.
✗ Branch 685 not taken.
✗ Branch 686 not taken.
✗ Branch 687 not taken.
✗ Branch 688 not taken.
✗ Branch 689 not taken.
✗ Branch 690 not taken.
✗ Branch 691 not taken.
✗ Branch 692 not taken.
✗ Branch 693 not taken.
✗ Branch 694 not taken.
✗ Branch 695 not taken.
✗ Branch 696 not taken.
✗ Branch 697 not taken.
✗ Branch 698 not taken.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✗ Branch 702 not taken.
✗ Branch 703 not taken.
✗ Branch 704 not taken.
✗ Branch 705 not taken.
✗ Branch 706 not taken.
✗ Branch 707 not taken.
✗ Branch 708 not taken.
✗ Branch 709 not taken.
✗ Branch 710 not taken.
✗ Branch 711 not taken.
✗ Branch 712 not taken.
✗ Branch 713 not taken.
✗ Branch 714 not taken.
✗ Branch 715 not taken.
✗ Branch 716 not taken.
✗ Branch 717 not taken.
✗ Branch 718 not taken.
✗ Branch 719 not taken.
✗ Branch 720 not taken.
✗ Branch 721 not taken.
✗ Branch 722 not taken.
✗ Branch 723 not taken.
✗ Branch 724 not taken.
✗ Branch 725 not taken.
✗ Branch 726 not taken.
✗ Branch 727 not taken.
✗ Branch 728 not taken.
✗ Branch 729 not taken.
✗ Branch 730 not taken.
✗ Branch 731 not taken.
✗ Branch 732 not taken.
✗ Branch 733 not taken.
✗ Branch 734 not taken.
✗ Branch 735 not taken.
✗ Branch 736 not taken.
✗ Branch 737 not taken.
✗ Branch 738 not taken.
✗ Branch 739 not taken.
✗ Branch 740 not taken.
✗ Branch 741 not taken.
✗ Branch 742 not taken.
✗ Branch 743 not taken.
✗ Branch 744 not taken.
✗ Branch 745 not taken.
✗ Branch 746 not taken.
✗ Branch 747 not taken.
✗ Branch 748 not taken.
✗ Branch 749 not taken.
✗ Branch 750 not taken.
✗ Branch 751 not taken.
✗ Branch 752 not taken.
✗ Branch 753 not taken.
✗ Branch 754 not taken.
✗ Branch 755 not taken.
✗ Branch 756 not taken.
✗ Branch 757 not taken.
✗ Branch 758 not taken.
✗ Branch 759 not taken.
✓ Branch 760 taken 952310006 times.
✗ Branch 761 not taken.
✓ Branch 762 taken 749311486 times.
✗ Branch 763 not taken.
✓ Branch 764 taken 6076 times.
✓ Branch 765 taken 28819 times.
✓ Branch 766 taken 15038008 times.
✓ Branch 767 taken 14897290 times.
✓ Branch 768 taken 562181 times.
✗ Branch 769 not taken.
✓ Branch 770 taken 2929 times.
✗ Branch 771 not taken.
✗ Branch 772 not taken.
✓ Branch 773 taken 2402 times.
✗ Branch 774 not taken.
✗ Branch 775 not taken.
✗ Branch 776 not taken.
✗ Branch 777 not taken.
✗ Branch 778 not taken.
✓ Branch 779 taken 766680 times.
✗ Branch 780 not taken.
✓ Branch 781 taken 468 times.
✗ Branch 782 not taken.
✗ Branch 783 not taken.
✗ Branch 784 not taken.
✗ Branch 785 not taken.
✗ Branch 786 not taken.
✗ Branch 787 not taken.
✗ Branch 788 not taken.
✗ Branch 789 not taken.
✗ Branch 790 not taken.
✗ Branch 791 not taken.
✗ Branch 792 not taken.
✗ Branch 793 not taken.
✗ Branch 794 not taken.
✗ Branch 795 not taken.
✗ Branch 796 not taken.
✗ Branch 797 not taken.
✗ Branch 798 not taken.
✗ Branch 799 not taken.
✗ Branch 800 not taken.
✗ Branch 801 not taken.
✗ Branch 802 not taken.
✗ Branch 803 not taken.
✗ Branch 804 not taken.
✗ Branch 805 not taken.
✗ Branch 806 not taken.
✗ Branch 807 not taken.
✗ Branch 808 not taken.
✗ Branch 809 not taken.
✗ Branch 810 not taken.
✗ Branch 811 not taken.
✓ Branch 812 taken 53 times.
✗ Branch 813 not taken.
✗ Branch 814 not taken.
✗ Branch 815 not taken.
✗ Branch 816 not taken.
✗ Branch 817 not taken.
✓ Branch 818 taken 901 times.
✗ Branch 819 not taken.
✗ Branch 820 not taken.
✗ Branch 821 not taken.
✗ Branch 822 not taken.
✗ Branch 823 not taken.
✗ Branch 824 not taken.
✗ Branch 825 not taken.
✗ Branch 826 not taken.
✗ Branch 827 not taken.
✓ Branch 828 taken 140 times.
✓ Branch 829 taken 1765 times.
✗ Branch 830 not taken.
✗ Branch 831 not taken.
✗ Branch 832 not taken.
✗ Branch 833 not taken.
✗ Branch 834 not taken.
✗ Branch 835 not taken.
✗ Branch 836 not taken.
✗ Branch 837 not taken.
✗ Branch 838 not taken.
✗ Branch 839 not taken.
✗ Branch 840 not taken.
✗ Branch 841 not taken.
✗ Branch 842 not taken.
✓ Branch 843 taken 50207 times.
✗ Branch 844 not taken.
✓ Branch 845 taken 50207 times.
✓ Branch 846 taken 61651 times.
✓ Branch 847 taken 134799 times.
✓ Branch 848 taken 73148 times.
✗ Branch 849 not taken.
✗ Branch 850 not taken.
✓ Branch 851 taken 77691 times.
✗ Branch 852 not taken.
✗ Branch 853 not taken.
✗ Branch 854 not taken.
✗ Branch 855 not taken.
✗ Branch 856 not taken.
✗ Branch 857 not taken.
✓ Branch 858 taken 426414 times.
✓ Branch 859 taken 436097 times.
✗ Branch 860 not taken.
✓ Branch 861 taken 410674 times.
✗ Branch 862 not taken.
✗ Branch 863 not taken.
✓ Branch 864 taken 5126984 times.
✗ Branch 865 not taken.
✓ Branch 866 taken 165740 times.
✗ Branch 867 not taken.
✓ Branch 868 taken 1130026 times.
✓ Branch 869 taken 472577 times.
✗ Branch 870 not taken.
✓ Branch 871 taken 532410 times.
✓ Branch 872 taken 3169 times.
✓ Branch 873 taken 13200 times.
✓ Branch 874 taken 5408 times.
✓ Branch 875 taken 39139 times.
✗ Branch 876 not taken.
✗ Branch 877 not taken.
✓ Branch 878 taken 404 times.
✗ Branch 879 not taken.
✓ Branch 880 taken 17988 times.
✗ Branch 881 not taken.
✗ Branch 882 not taken.
✓ Branch 883 taken 6086 times.
✓ Branch 884 taken 383015 times.
✓ Branch 885 taken 383015 times.
✓ Branch 886 taken 427914 times.
✓ Branch 887 taken 427914 times.
✓ Branch 888 taken 226198 times.
✗ Branch 889 not taken.
✓ Branch 890 taken 1505295 times.
✓ Branch 891 taken 1487420 times.
✓ Branch 892 taken 1058433 times.
✗ Branch 893 not taken.
✓ Branch 894 taken 1035974 times.
✓ Branch 895 taken 603415 times.
✓ Branch 896 taken 2064045 times.
✓ Branch 897 taken 2065021 times.
✗ Branch 898 not taken.
✗ Branch 899 not taken.
✗ Branch 900 not taken.
✓ Branch 901 taken 2064017 times.
✓ Branch 902 taken 75623 times.
✗ Branch 903 not taken.
✗ Branch 904 not taken.
✗ Branch 905 not taken.
✗ Branch 906 not taken.
✗ Branch 907 not taken.
✗ Branch 908 not taken.
✓ Branch 909 taken 527244 times.
✗ Branch 910 not taken.
✓ Branch 911 taken 22519029 times.
✗ Branch 912 not taken.
✓ Branch 913 taken 598 times.
✗ Branch 914 not taken.
✓ Branch 915 taken 3672930 times.
✓ Branch 916 taken 167669 times.
✓ Branch 917 taken 268246 times.
✗ Branch 918 not taken.
✓ Branch 919 taken 11384507 times.
✗ Branch 920 not taken.
✗ Branch 921 not taken.
✓ Branch 922 taken 6431345 times.
✗ Branch 923 not taken.
✗ Branch 924 not taken.
✗ Branch 925 not taken.
✗ Branch 926 not taken.
✗ Branch 927 not taken.
✗ Branch 928 not taken.
✗ Branch 929 not taken.
✗ Branch 930 not taken.
✗ Branch 931 not taken.
✗ Branch 932 not taken.
✗ Branch 933 not taken.
✗ Branch 934 not taken.
✗ Branch 935 not taken.
✗ Branch 936 not taken.
✓ Branch 937 taken 218 times.
✓ Branch 938 taken 16 times.
✗ Branch 939 not taken.
✗ Branch 940 not taken.
✗ Branch 941 not taken.
✗ Branch 942 not taken.
✗ Branch 943 not taken.
✗ Branch 944 not taken.
✗ Branch 945 not taken.
✗ Branch 946 not taken.
✗ Branch 947 not taken.
✗ Branch 948 not taken.
✓ Branch 949 taken 191517 times.
✓ Branch 950 taken 1218351 times.
✗ Branch 951 not taken.
✗ Branch 952 not taken.
✗ Branch 953 not taken.
✗ Branch 954 not taken.
✗ Branch 955 not taken.
✓ Branch 956 taken 18739404 times.
✓ Branch 957 taken 5921469 times.
✗ Branch 958 not taken.
✗ Branch 959 not taken.
✗ Branch 960 not taken.
✗ Branch 961 not taken.
✗ Branch 962 not taken.
✗ Branch 963 not taken.
✗ Branch 964 not taken.
✗ Branch 965 not taken.
✗ Branch 966 not taken.
✗ Branch 967 not taken.
✓ Branch 968 taken 1764243 times.
✓ Branch 969 taken 1019 times.
✓ Branch 970 taken 255560 times.
✗ Branch 971 not taken.
✓ Branch 972 taken 741668 times.
✓ Branch 973 taken 95414 times.
✓ Branch 974 taken 9482 times.
✓ Branch 975 taken 37 times.
✓ Branch 976 taken 27341446 times.
✓ Branch 977 taken 2709583 times.
✓ Branch 978 taken 3906326 times.
✓ Branch 979 taken 26494389 times.
✓ Branch 980 taken 2975118 times.
✓ Branch 981 taken 96784 times.
✗ Branch 982 not taken.
✓ Branch 983 taken 13758809 times.
✓ Branch 984 taken 2272124 times.
✓ Branch 985 taken 5866709 times.
✓ Branch 986 taken 449777 times.
✓ Branch 987 taken 421915 times.
✓ Branch 988 taken 6342577 times.
✗ Branch 989 not taken.
✗ Branch 990 not taken.
✗ Branch 991 not taken.
✗ Branch 992 not taken.
✗ Branch 993 not taken.
✗ Branch 994 not taken.
✗ Branch 995 not taken.
✗ Branch 996 not taken.
✗ Branch 997 not taken.
✗ Branch 998 not taken.
✗ Branch 999 not taken.
✗ Branch 1000 not taken.
✗ Branch 1001 not taken.
✗ Branch 1002 not taken.
✗ Branch 1003 not taken.
✗ Branch 1004 not taken.
✗ Branch 1005 not taken.
✗ Branch 1006 not taken.
✓ Branch 1007 taken 390022 times.
✗ Branch 1008 not taken.
✗ Branch 1009 not taken.
✗ Branch 1010 not taken.
✓ Branch 1011 taken 229611 times.
✓ Branch 1012 taken 91 times.
✗ Branch 1013 not taken.
✗ Branch 1014 not taken.
✗ Branch 1015 not taken.
✗ Branch 1016 not taken.
✗ Branch 1017 not taken.
✗ Branch 1018 not taken.
✗ Branch 1019 not taken.
✗ Branch 1020 not taken.
✗ Branch 1021 not taken.
✗ Branch 1022 not taken.
✗ Branch 1023 not taken.
✗ Branch 1024 not taken.
✗ Branch 1025 not taken.
✗ Branch 1026 not taken.
✗ Branch 1027 not taken.
✗ Branch 1028 not taken.
✗ Branch 1029 not taken.
✗ Branch 1030 not taken.
✗ Branch 1031 not taken.
✗ Branch 1032 not taken.
✗ Branch 1033 not taken.
✗ Branch 1034 not taken.
✗ Branch 1035 not taken.
✗ Branch 1036 not taken.
✗ Branch 1037 not taken.
✗ Branch 1038 not taken.
✗ Branch 1039 not taken.
✗ Branch 1040 not taken.
✗ Branch 1041 not taken.
✗ Branch 1042 not taken.
✗ Branch 1043 not taken.
✗ Branch 1044 not taken.
✗ Branch 1045 not taken.
✗ Branch 1046 not taken.
✗ Branch 1047 not taken.
✗ Branch 1048 not taken.
✗ Branch 1049 not taken.
✗ Branch 1050 not taken.
✗ Branch 1051 not taken.
✗ Branch 1052 not taken.
✗ Branch 1053 not taken.
✗ Branch 1054 not taken.
✗ Branch 1055 not taken.
✗ Branch 1056 not taken.
✗ Branch 1057 not taken.
✗ Branch 1058 not taken.
✗ Branch 1059 not taken.
✗ Branch 1060 not taken.
✓ Branch 1061 taken 6 times.
✓ Branch 1062 taken 6 times.
✗ Branch 1063 not taken.
✗ Branch 1064 not taken.
✗ Branch 1065 not taken.
✗ Branch 1066 not taken.
✓ Branch 1067 taken 128 times.
✓ Branch 1068 taken 128 times.
✓ Branch 1069 taken 128 times.
✗ Branch 1070 not taken.
✗ Branch 1071 not taken.
✗ Branch 1072 not taken.
✓ Branch 1073 taken 5 times.
✓ Branch 1074 taken 5 times.
✓ Branch 1075 taken 5 times.
✓ Branch 1076 taken 389 times.
✓ Branch 1077 taken 389 times.
✓ Branch 1078 taken 5 times.
✓ Branch 1079 taken 5 times.
✓ Branch 1080 taken 5 times.
✓ Branch 1081 taken 5 times.
✓ Branch 1082 taken 70 times.
✗ Branch 1083 not taken.
✓ Branch 1084 taken 32 times.
✗ Branch 1085 not taken.
✗ Branch 1086 not taken.
✗ Branch 1087 not taken.
✗ Branch 1088 not taken.
✓ Branch 1089 taken 5 times.
✓ Branch 1090 taken 5 times.
✓ Branch 1091 taken 5 times.
✓ Branch 1092 taken 5 times.
✗ Branch 1093 not taken.
✓ Branch 1094 taken 32773 times.
✓ Branch 1095 taken 1800 times.
✗ Branch 1096 not taken.
✗ Branch 1097 not taken.
✗ Branch 1098 not taken.
✗ Branch 1099 not taken.
✗ Branch 1100 not taken.
✗ Branch 1101 not taken.
✗ Branch 1102 not taken.
✗ Branch 1103 not taken.
✗ Branch 1104 not taken.
✗ Branch 1105 not taken.
✗ Branch 1106 not taken.
✗ Branch 1107 not taken.
✗ Branch 1108 not taken.
✗ Branch 1109 not taken.
✗ Branch 1110 not taken.
✓ Branch 1111 taken 4767898 times.
✓ Branch 1112 taken 4654485 times.
✓ Branch 1113 taken 5945377 times.
✓ Branch 1114 taken 2538431 times.
✓ Branch 1115 taken 345816 times.
✓ Branch 1116 taken 85947 times.
✗ Branch 1117 not taken.
✗ Branch 1118 not taken.
✗ Branch 1119 not taken.
✗ Branch 1120 not taken.
✗ Branch 1121 not taken.
✗ Branch 1122 not taken.
✗ Branch 1123 not taken.
✗ Branch 1124 not taken.
✗ Branch 1125 not taken.
✗ Branch 1126 not taken.
✗ Branch 1127 not taken.
✗ Branch 1128 not taken.
✗ Branch 1129 not taken.
✗ Branch 1130 not taken.
✗ Branch 1131 not taken.
✗ Branch 1132 not taken.
✗ Branch 1133 not taken.
✓ Branch 1134 taken 24 times.
✗ Branch 1135 not taken.
✗ Branch 1136 not taken.
✗ Branch 1137 not taken.
✗ Branch 1138 not taken.
✗ Branch 1139 not taken.
✗ Branch 1140 not taken.
✗ Branch 1141 not taken.
✗ Branch 1142 not taken.
✗ Branch 1143 not taken.
✗ Branch 1144 not taken.
✗ Branch 1145 not taken.
✗ Branch 1146 not taken.
✗ Branch 1147 not taken.
✗ Branch 1148 not taken.
✗ Branch 1149 not taken.
✗ Branch 1150 not taken.
✗ Branch 1151 not taken.
✗ Branch 1152 not taken.
✗ Branch 1153 not taken.
✗ Branch 1154 not taken.
✗ Branch 1155 not taken.
✗ Branch 1156 not taken.
✗ Branch 1157 not taken.
✗ Branch 1158 not taken.
✗ Branch 1159 not taken.
✗ Branch 1160 not taken.
✗ Branch 1161 not taken.
✗ Branch 1162 not taken.
✗ Branch 1163 not taken.
✗ Branch 1164 not taken.
✗ Branch 1165 not taken.
✗ Branch 1166 not taken.
✓ Branch 1167 taken 11261 times.
✓ Branch 1168 taken 11261 times.
✓ Branch 1169 taken 33759 times.
✓ Branch 1170 taken 11044 times.
✓ Branch 1171 taken 4546 times.
✗ Branch 1172 not taken.
✗ Branch 1173 not taken.
✗ Branch 1174 not taken.
✗ Branch 1175 not taken.
✓ Branch 1176 taken 4546 times.
✗ Branch 1177 not taken.
✗ Branch 1178 not taken.
✓ Branch 1179 taken 4890 times.
✗ Branch 1180 not taken.
✗ Branch 1181 not taken.
✓ Branch 1182 taken 22172 times.
✗ Branch 1183 not taken.
✗ Branch 1184 not taken.
✗ Branch 1185 not taken.
✗ Branch 1186 not taken.
✗ Branch 1187 not taken.
✗ Branch 1188 not taken.
✗ Branch 1189 not taken.
✗ Branch 1190 not taken.
✗ Branch 1191 not taken.
✓ Branch 1192 taken 66 times.
✓ Branch 1193 taken 1636 times.
✓ Branch 1194 taken 568 times.
✓ Branch 1195 taken 136 times.
✗ Branch 1196 not taken.
✗ Branch 1197 not taken.
✗ Branch 1198 not taken.
✗ Branch 1199 not taken.
✗ Branch 1200 not taken.
✗ Branch 1201 not taken.
✗ Branch 1202 not taken.
✗ Branch 1203 not taken.
✗ Branch 1204 not taken.
✗ Branch 1205 not taken.
✗ Branch 1206 not taken.
✗ Branch 1207 not taken.
✗ Branch 1208 not taken.
✗ Branch 1209 not taken.
✗ Branch 1210 not taken.
✗ Branch 1211 not taken.
✗ Branch 1212 not taken.
✗ Branch 1213 not taken.
✗ Branch 1214 not taken.
✗ Branch 1215 not taken.
✗ Branch 1216 not taken.
✗ Branch 1217 not taken.
✗ Branch 1218 not taken.
✗ Branch 1219 not taken.
✗ Branch 1220 not taken.
✗ Branch 1221 not taken.
✗ Branch 1222 not taken.
✗ Branch 1223 not taken.
✗ Branch 1224 not taken.
✗ Branch 1225 not taken.
✗ Branch 1226 not taken.
✗ Branch 1227 not taken.
✗ Branch 1228 not taken.
✗ Branch 1229 not taken.
✗ Branch 1230 not taken.
✗ Branch 1231 not taken.
✗ Branch 1232 not taken.
✗ Branch 1233 not taken.
✗ Branch 1234 not taken.
✗ Branch 1235 not taken.
✗ Branch 1236 not taken.
✗ Branch 1237 not taken.
✗ Branch 1238 not taken.
✗ Branch 1239 not taken.
✗ Branch 1240 not taken.
✗ Branch 1241 not taken.
✗ Branch 1242 not taken.
✗ Branch 1243 not taken.
✗ Branch 1244 not taken.
✗ Branch 1245 not taken.
✗ Branch 1246 not taken.
✗ Branch 1247 not taken.
✗ Branch 1248 not taken.
✗ Branch 1249 not taken.
✗ Branch 1250 not taken.
✗ Branch 1251 not taken.
✗ Branch 1252 not taken.
✗ Branch 1253 not taken.
✗ Branch 1254 not taken.
✗ Branch 1255 not taken.
✗ Branch 1256 not taken.
✗ Branch 1257 not taken.
✗ Branch 1258 not taken.
✗ Branch 1259 not taken.
✗ Branch 1260 not taken.
✗ Branch 1261 not taken.
✗ Branch 1262 not taken.
✗ Branch 1263 not taken.
✗ Branch 1264 not taken.
✗ Branch 1265 not taken.
✗ Branch 1266 not taken.
✗ Branch 1267 not taken.
✗ Branch 1268 not taken.
✗ Branch 1269 not taken.
✗ Branch 1270 not taken.
✗ Branch 1271 not taken.
✗ Branch 1272 not taken.
✗ Branch 1273 not taken.
✗ Branch 1274 not taken.
✗ Branch 1275 not taken.
✗ Branch 1276 not taken.
✗ Branch 1277 not taken.
✗ Branch 1278 not taken.
✗ Branch 1279 not taken.
✗ Branch 1280 not taken.
✗ Branch 1281 not taken.
✗ Branch 1282 not taken.
✗ Branch 1283 not taken.
✗ Branch 1284 not taken.
✗ Branch 1285 not taken.
✗ Branch 1286 not taken.
✗ Branch 1287 not taken.
✗ Branch 1288 not taken.
✗ Branch 1289 not taken.
✗ Branch 1290 not taken.
✗ Branch 1291 not taken.
✗ Branch 1292 not taken.
✗ Branch 1293 not taken.
✗ Branch 1294 not taken.
✗ Branch 1295 not taken.
✗ Branch 1296 not taken.
✗ Branch 1297 not taken.
✗ Branch 1298 not taken.
✗ Branch 1299 not taken.
✗ Branch 1300 not taken.
✗ Branch 1301 not taken.
✗ Branch 1302 not taken.
✗ Branch 1303 not taken.
✗ Branch 1304 not taken.
✗ Branch 1305 not taken.
✗ Branch 1306 not taken.
✗ Branch 1307 not taken.
✗ Branch 1308 not taken.
✗ Branch 1309 not taken.
✗ Branch 1310 not taken.
✗ Branch 1311 not taken.
✗ Branch 1312 not taken.
✗ Branch 1313 not taken.
✗ Branch 1314 not taken.
✗ Branch 1315 not taken.
✗ Branch 1316 not taken.
✗ Branch 1317 not taken.
✗ Branch 1318 not taken.
✗ Branch 1319 not taken.
✗ Branch 1320 not taken.
✗ Branch 1321 not taken.
✗ Branch 1322 not taken.
✗ Branch 1323 not taken.
✗ Branch 1324 not taken.
✗ Branch 1325 not taken.
✗ Branch 1326 not taken.
✗ Branch 1327 not taken.
✗ Branch 1328 not taken.
✗ Branch 1329 not taken.
✗ Branch 1330 not taken.
✗ Branch 1331 not taken.
✗ Branch 1332 not taken.
✗ Branch 1333 not taken.
✗ Branch 1334 not taken.
✗ Branch 1335 not taken.
✗ Branch 1336 not taken.
✗ Branch 1337 not taken.
✗ Branch 1338 not taken.
✗ Branch 1339 not taken.
✗ Branch 1340 not taken.
✗ Branch 1341 not taken.
✗ Branch 1342 not taken.
✗ Branch 1343 not taken.
✗ Branch 1344 not taken.
✗ Branch 1345 not taken.
✗ Branch 1346 not taken.
✗ Branch 1347 not taken.
✗ Branch 1348 not taken.
✗ Branch 1349 not taken.
✗ Branch 1350 not taken.
✗ Branch 1351 not taken.
✗ Branch 1352 not taken.
✗ Branch 1353 not taken.
✗ Branch 1354 not taken.
✗ Branch 1355 not taken.
✗ Branch 1356 not taken.
✗ Branch 1357 not taken.
✗ Branch 1358 not taken.
✗ Branch 1359 not taken.
✗ Branch 1360 not taken.
✗ Branch 1361 not taken.
✗ Branch 1362 not taken.
✗ Branch 1363 not taken.
✗ Branch 1364 not taken.
✗ Branch 1365 not taken.
✗ Branch 1366 not taken.
✗ Branch 1367 not taken.
✗ Branch 1368 not taken.
✗ Branch 1369 not taken.
✗ Branch 1370 not taken.
✗ Branch 1371 not taken.
✗ Branch 1372 not taken.
✗ Branch 1373 not taken.
✗ Branch 1374 not taken.
✗ Branch 1375 not taken.
✗ Branch 1376 not taken.
✗ Branch 1377 not taken.
✗ Branch 1378 not taken.
✗ Branch 1379 not taken.
✗ Branch 1380 not taken.
✗ Branch 1381 not taken.
✗ Branch 1382 not taken.
✗ Branch 1383 not taken.
✗ Branch 1384 not taken.
✗ Branch 1385 not taken.
✗ Branch 1386 not taken.
✗ Branch 1387 not taken.
✗ Branch 1388 not taken.
✗ Branch 1389 not taken.
✗ Branch 1390 not taken.
✗ Branch 1391 not taken.
✗ Branch 1392 not taken.
✗ Branch 1393 not taken.
✗ Branch 1394 not taken.
✗ Branch 1395 not taken.
✗ Branch 1396 not taken.
✗ Branch 1397 not taken.
✗ Branch 1398 not taken.
✗ Branch 1399 not taken.
✗ Branch 1400 not taken.
✗ Branch 1401 not taken.
✗ Branch 1402 not taken.
✗ Branch 1403 not taken.
✗ Branch 1404 not taken.
✗ Branch 1405 not taken.
✗ Branch 1406 not taken.
✗ Branch 1407 not taken.
✗ Branch 1408 not taken.
✗ Branch 1409 not taken.
✗ Branch 1410 not taken.
2760742172 switch(arg)
3769 {
3770
3771 case INCQST:
3772 {
3773 //zprint2("Incrementing Quest\n");
3774 int32_t newqst = 0;
3775 if ( game->get_quest() < 255 ) //255 is a custom quest
3776 {
3777 newqst = (game->get_quest()+1);
3778 }
3779 else
3780 {
3781 newqst = 1;
3782 }
3783 //zprint2("newqst is: %d\n", newqst);
3784 if ( newqst < 11 )
3785 {
3786
3787 ret = newqst * 10000;
3788 Quit = qINCQST;
3789 //ending();
3790
3791 }
3792 else ret = -10000;
3793 break;
3794 }
3795 //Debug->Null()
3796 case DONULL:
3797 ret = 0;
3798 break;
3799 case DEBUGTESTING:
3800 43 ret = use_testingst_start ? 10000 : 0;
3801 43 break;
3802
3803 //debug ri->d[]
3804 case DEBUGD:
3805 {
3806 int32_t a = ri->d[rINDEX] / 10000;
3807 ret = ri->d[a] * 10000;
3808 break;
3809 }
3810
3811 ///----------------------------------------------------------------------------------------------------//
3812 //FFC Variables
3813 case DATA:
3814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440400 times.
4440400 if(BC::checkFFC(ri->ffcref, "ffc->Data") == SH::_NoError)
3815 4440400 ret = tmpscr->ffcs[ri->ffcref].data *10000;
3816 4440400 break;
3817
3818 case FFSCRIPT:
3819
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 468470857 times.
468471069 if(BC::checkFFC(ri->ffcref, "ffc->Script") == SH::_NoError)
3820 468470857 ret = tmpscr->ffcs[ri->ffcref].script*10000;
3821 468471069 break;
3822
3823 case FCSET:
3824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1184834 times.
1184834 if(BC::checkFFC(ri->ffcref, "ffc->CSet") == SH::_NoError)
3825 1184834 ret = tmpscr->ffcs[ri->ffcref].cset*10000;
3826 1184834 break;
3827
3828 case DELAY:
3829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(BC::checkFFC(ri->ffcref, "ffc->Delay") == SH::_NoError)
3830 5 ret = tmpscr->ffcs[ri->ffcref].delay*10000;
3831 5 break;
3832
3833 case FX:
3834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8343962 times.
8343962 if(BC::checkFFC(ri->ffcref, "ffc->X") == SH::_NoError)
3835 8343962 ret = tmpscr->ffcs[ri->ffcref].x.getZLong();
3836 8343962 break;
3837
3838 case FY:
3839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7892556 times.
7892556 if(BC::checkFFC(ri->ffcref, "ffc->Y") == SH::_NoError)
3840 7892556 ret = tmpscr->ffcs[ri->ffcref].y.getZLong();
3841 7892556 break;
3842
3843 case XD:
3844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Vx") == SH::_NoError)
3845 35 ret = tmpscr->ffcs[ri->ffcref].vx.getZLong();
3846 35 break;
3847
3848 case YD:
3849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Vy") == SH::_NoError)
3850 35 ret = tmpscr->ffcs[ri->ffcref].vy.getZLong();
3851 35 break;
3852 case FFCID:
3853 if(BC::checkFFC(ri->ffcref, "ffc->ID") == SH::_NoError)
3854 ret=(ri->ffcref*10000)+10000;
3855 break;
3856
3857 case XD2:
3858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Ax") == SH::_NoError)
3859 35 ret = tmpscr->ffcs[ri->ffcref].ax.getZLong();
3860 35 break;
3861
3862 case YD2:
3863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Ay") == SH::_NoError)
3864 35 ret = tmpscr->ffcs[ri->ffcref].ay.getZLong();
3865 35 break;
3866
3867 case FFFLAGSD:
3868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2180472 times.
2180472 if(BC::checkFFC(ri->ffcref, "ffc->Flags[]") == SH::_NoError)
3869 2180472 ret=((tmpscr->ffcs[ri->ffcref].flags >> (ri->d[rINDEX] / 10000))&1) ? 10000 : 0;
3870 2180472 break;
3871
3872 case FFCWIDTH:
3873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(BC::checkFFC(ri->ffcref, "ffc->EffectWidth") == SH::_NoError)
3874 103 ret=(tmpscr->ffcs[ri->ffcref].hit_width*10000);
3875 103 break;
3876
3877 case FFCHEIGHT:
3878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(BC::checkFFC(ri->ffcref, "ffc->EffectHeight") == SH::_NoError)
3879 98 ret=(tmpscr->ffcs[ri->ffcref].hit_height*10000);
3880 98 break;
3881
3882 case FFTWIDTH:
3883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2596310 times.
2596310 if(BC::checkFFC(ri->ffcref, "ffc->TileWidth") == SH::_NoError)
3884 2596310 ret=(tmpscr->ffcs[ri->ffcref].txsz*10000);
3885 2596310 break;
3886
3887 case FFTHEIGHT:
3888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2596581 times.
2596581 if(BC::checkFFC(ri->ffcref, "ffc->TileHeight") == SH::_NoError)
3889 2596581 ret=(tmpscr->ffcs[ri->ffcref].tysz*10000);
3890 2596581 break;
3891
3892 case FFLINK:
3893 if(BC::checkFFC(ri->ffcref, "ffc->Link") == SH::_NoError)
3894 ret=(tmpscr->ffcs[ri->ffcref].link)*10000;
3895 break;
3896
3897 case FFMISCD:
3898 {
3899 6076 int32_t a = ri->d[rINDEX] / 10000;
3900
3901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6076 times.
6076 if(BC::checkMisc(a, "ffc->Misc") != SH::_NoError)
3902 ret = -10000;
3903 else
3904 {
3905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6076 times.
6076 if(BC::checkFFC(ri->ffcref, "ffc->Misc[]") == SH::_NoError)
3906 6076 ret = ffmisc[ri->ffcref][a];
3907 }
3908 }
3909 6076 break;
3910
3911 case FFINITDD:
3912 {
3913 28819 int32_t a = ri->d[rINDEX] / 10000;
3914
3915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28819 times.
28819 if(BC::checkBounds(a, 0, 7, "ffc->InitD") != SH::_NoError)
3916 ret = -10000;
3917 else
3918 {
3919
2/2
✓ Branch 0 taken 28802 times.
✓ Branch 1 taken 17 times.
28819 if(BC::checkFFC(ri->ffcref, "ffc->InitD[]") == SH::_NoError)
3920 28802 ret = tmpscr->ffcs[ri->ffcref].initd[a];
3921 }
3922 }
3923 28819 break;
3924
3925 ///----------------------------------------------------------------------------------------------------//
3926 //Hero's Variables
3927 case LINKX:
3928 {
3929
2/2
✓ Branch 0 taken 1449451 times.
✓ Branch 1 taken 13588557 times.
15038008 if (get_qr(qr_SPRITEXY_IS_FLOAT))
3930 {
3931 //double lx = (double)Hero.getX();
3932 //Z_scripterrlog("lx: %f\n", lx);
3933
3934 //ret = lx * 10000;
3935 //zfix lx = Hero.getX();
3936 //Z_scripterrlog("lx: %d\n", lx);
3937 1449451 ret = Hero.getX().getZLong();
3938 1449451 }
3939 13588557 else ret = int32_t(Hero.getX()) * 10000;
3940
3941 15038008 break;
3942 }
3943
3944 case LINKCSET:
3945 {
3946 1282 ret = Hero.cs * 10000;
3947 1282 break;
3948 }
3949 case LINKY:
3950 {
3951
2/2
✓ Branch 0 taken 1415493 times.
✓ Branch 1 taken 13481797 times.
14897290 if (get_qr(qr_SPRITEXY_IS_FLOAT))
3952 {
3953 1415493 ret = Hero.getY().getZLong();
3954 1415493 }
3955 13481797 else ret = int32_t(Hero.getY()) * 10000;
3956
3957 14897290 break;
3958 }
3959 case LINKZ:
3960 {
3961
2/2
✓ Branch 0 taken 93233 times.
✓ Branch 1 taken 468948 times.
562181 if (get_qr(qr_SPRITEXY_IS_FLOAT))
3962 {
3963 93233 ret = Hero.getZ().getZLong();
3964 93233 }
3965 468948 else ret = int32_t(Hero.getZ()) * 10000;
3966
3967 562181 break;
3968 }
3969 case LINKJUMP:
3970 // -fall/100*10000, but doing it that way screwed up the result
3971 641181 ret = Hero.getFall().getZLong() / -100;
3972 641181 break;
3973
3974 case HEROFAKEJUMP:
3975 ret = Hero.getFakeFall().getZLong() / -100;
3976 break;
3977
3978 case LINKDIR:
3979 756380 ret=(int32_t)(Hero.dir)*10000;
3980 756380 break;
3981
3982 case LINKHITDIR:
3983 ret=(int32_t)(Hero.getHitDir())*10000;
3984 break;
3985
3986 case LINKHP:
3987 15444108 ret=(int32_t)(game->get_life())*10000;
3988 15444108 break;
3989
3990 case LINKGRAVITY:
3991 ret = ( (Hero.moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0 );
3992 break;
3993
3994 case HERONOSTEPFORWARD:
3995 ret = ( (FFCore.nostepforward) ? 10000 : 0 );
3996 break;
3997
3998 case LINKMP:
3999 2112268 ret=(int32_t)(game->get_magic())*10000;
4000 2112268 break;
4001
4002 case LINKMAXHP:
4003 655865 ret=(int32_t)(game->get_maxlife())*10000;
4004 655865 break;
4005
4006 case LINKMAXMP:
4007 552027 ret=(int32_t)(game->get_maxmagic())*10000;
4008 552027 break;
4009
4010 case LINKACTION:
4011 {
4012 //Z_scripterrlog("The present FFCore action is: %d\n", FFCore.getHeroAction());
4013 //int32_t act = FFCore.getHeroAction() * 10000;
4014 44798253 ret = FFCore.getHeroAction() * 10000;
4015 //Z_scripterrlog("The present 'action' return value is: %d\n", act);
4016 //ret = act;
4017 //ret=(int32_t)(Hero.getAction())*10000;
4018 44798253 break;
4019 }
4020
4021 case HEROHEALTHBEEP:
4022 {
4023 //Z_scripterrlog("The present FFCore action is: %d\n", FFCore.getHeroAction());
4024 //int32_t act = FFCore.getHeroAction() * 10000;
4025 ret = heart_beep ? ( heart_beep_timer * 10000 ) : 0;
4026 //Z_scripterrlog("The present 'action' return value is: %d\n", act);
4027 //ret = act;
4028 //ret=(int32_t)(Hero.getAction())*10000;
4029 break;
4030 }
4031
4032 case LINKHELD:
4033 17 ret = (int32_t)(Hero.getHeldItem())*10000;
4034 17 break;
4035
4036 case LINKITEMD:
4037 19585851 ret = game->item[vbound(ri->d[rINDEX]/10000, 0, MAXITEMS-1)] ? 10000 : 0;
4038 19585851 break;
4039
4040 case HEROSTEPS:
4041 ret = lsteps[vbound(ri->d[rINDEX]/10000, 0, 7)] * 10000;
4042 break;
4043
4044 case HEROSTEPRATE:
4045 5424 ret = Hero.getStepRate() * 10000;
4046 5424 break;
4047 case HEROSHOVEOFFSET:
4048 ret = Hero.shove_offset.getZLong();
4049 break;
4050
4051 case LINKEQUIP:
4052 801725 ret = ((Awpn&0xFF)|((Bwpn&0xFF)<<8))*10000;
4053 801725 break;
4054
4055 case LINKINVIS:
4056 557644 ret = (((int32_t)(Hero.getDontDraw())) ? 10000 : 0);
4057 557644 break;
4058
4059 case LINKINVINC:
4060 623338 ret = (int32_t)(Hero.scriptcoldet)*10000;
4061 623338 break;
4062
4063 case LINKENGINEANIMATE:
4064 ret = (int32_t)(Hero.do_animation)*10000;
4065 break;
4066
4067 case LINKLADDERX:
4068 ret=(int32_t)(Hero.getLadderX())*10000;
4069 break;
4070
4071 case LINKLADDERY:
4072 ret=(int32_t)(Hero.getLadderY())*10000;
4073 break;
4074
4075 case LINKSWORDJINX:
4076 280566 ret = (int32_t)(Hero.getSwordClk())*10000;
4077 280566 break;
4078
4079 case LINKITEMJINX:
4080 481556 ret = (int32_t)(Hero.getItemClk())*10000;
4081 481556 break;
4082
4083 case LINKDRUNK:
4084 ret = (int32_t)(Hero.DrunkClock())*10000;
4085 break;
4086
4087 case LINKMISCD:
4088 6213788 ret = (int32_t)(Hero.miscellaneous[vbound(ri->d[rINDEX]/10000,0,31)]); //Was this buffed before? -Z
4089 6213788 break;
4090
4091
4092 case LINKHITBY:
4093 {
4094 2929 int32_t indx = ri->d[rINDEX]/10000;
4095
1/3
✓ Branch 0 taken 2929 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2929 switch(indx)
4096 {
4097 //screen indices of objects
4098 case 0:
4099 case 1:
4100 case 2:
4101 case 3:
4102 case 8:
4103 case 9:
4104 case 10:
4105 case 11:
4106 case 12:
4107 case 16:
4108 {
4109 2929 ret = (int32_t)(Hero.gethitHeroUID(indx))* 10000;
4110 2929 break;
4111 }
4112 //uids of objects
4113 case 4:
4114 case 5:
4115 case 6:
4116 case 7:
4117 case 13:
4118 case 14:
4119 case 15:
4120 {
4121 ret = (int32_t)(Hero.gethitHeroUID(indx)); //do not multiply by 10000! UIDs are not *10000!
4122 break;
4123 }
4124 default: { Z_scripterrlog("Invalid index passed to Player->HitBy[%d]/n", indx); ret = -1; break; }
4125 }
4126 2929 break;
4127 }
4128 case LINKDEFENCE:
4129 ret = (int32_t)(Hero.get_defence(vbound(ri->d[rINDEX]/10000,0,255)))* 10000;
4130 break;
4131
4132
4133 case LINKROTATION:
4134 if ( get_qr(qr_OLDSPRITEDRAWS) )
4135 {
4136 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
4137 "Player->Rotation");
4138 ret = -1; break;
4139 }
4140 ret = (int32_t)(Hero.rotation)*10000;
4141 break;
4142
4143 case LINKSCALE:
4144 {
4145 if ( get_qr(qr_OLDSPRITEDRAWS) )
4146 {
4147 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
4148 "Player->Scale");
4149 ret = -1; break;
4150 }
4151 //al_trace("Player's scale is: %d\n", Hero.scale);
4152 ret = (int32_t)(Hero.scale*100.0);
4153 break;
4154 }
4155
4156
4157 case LINKHXOFS:
4158 206522 ret = (int32_t)(Hero.hxofs)*10000;
4159 206522 break;
4160
4161 case LINKHYOFS:
4162 206522 ret = (int32_t)(Hero.hyofs)*10000;
4163 206522 break;
4164
4165 case LINKXOFS:
4166 ret = (int32_t)(Hero.xofs)*10000;
4167 break;
4168
4169 case LINKYOFS:
4170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2402 times.
2402 ret = (int32_t)(Hero.yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))*10000;
4171 2402 break;
4172
4173 case HEROSHADOWXOFS:
4174 ret = (int32_t)(Hero.shadowxofs)*10000;
4175 break;
4176
4177 case HEROSHADOWYOFS:
4178 ret = (int32_t)(Hero.shadowyofs)*10000;
4179 break;
4180
4181 case HEROTOTALDYOFFS:
4182 ret = 10000*(((int32_t)(Hero.yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))
4183 + ((Hero.switch_hooked && Hero.switchhookstyle == swRISE)
4184 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0));
4185 break;
4186
4187 case LINKZOFS:
4188 ret = (int32_t)(Hero.zofs)*10000;
4189 break;
4190
4191 case LINKHXSZ:
4192 206547 ret = (int32_t)(Hero.hit_width)*10000;
4193 206547 break;
4194
4195 case LINKHYSZ:
4196 206547 ret = (int32_t)(Hero.hit_height)*10000;
4197 206547 break;
4198
4199 case LINKHZSZ:
4200 173466 ret = (int32_t)(Hero.hzsz)*10000;
4201 173466 break;
4202
4203 case LINKTXSZ:
4204 ret = (int32_t)(Hero.txsz)*10000;
4205 break;
4206
4207 case LINKTYSZ:
4208 ret = (int32_t)(Hero.tysz)*10000;
4209 break;
4210
4211 case LINKTILE:
4212 4636 ret = (int32_t)(Hero.tile)*10000;
4213 4636 break;
4214
4215 case LINKFLIP:
4216 ret = (int32_t)(Hero.flip)*10000;
4217 break;
4218
4219 case LINKINVFRAME:
4220 ret = (int32_t)Hero.getHClk()*10000;
4221 break;
4222
4223 case LINKCANFLICKER:
4224 ret= Hero.getCanFlicker()?10000:0;
4225 break;
4226 case LINKHURTSFX:
4227 ret = (int32_t)Hero.getHurtSFX()*10000;
4228 break;
4229
4230 /*
4231 case LINKUSINGITEM:
4232 ret = (int32_t)Hero.getDirectItem()*10000;
4233 break;
4234
4235 case LINKUSINGITEMA:
4236 ret = (int32_t)Hero.getDirectItemA()*10000;
4237 break;
4238
4239 case LINKUSINGITEMB:
4240 ret = (int32_t)Hero.getDirectItemB()*10000;
4241 break;
4242 */
4243
4244 case LINKEATEN:
4245 ret=(int32_t)Hero.getEaten()*10000;
4246 break;
4247 case LINKGRABBED:
4248 ret = Hero.inwallm ? 10000 : 0;
4249 break;
4250 case HEROBUNNY:
4251 ret = Hero.BunnyClock()*10000;
4252 break;
4253 case LINKPUSH:
4254 ret=(int32_t)Hero.getPushing()*10000;
4255 break;
4256 case LINKSTUN:
4257 ret=(int32_t)Hero.StunClock()*10000;
4258 break;
4259 case LINKSCRIPTTILE:
4260 2 ret=script_hero_sprite*10000;
4261 2 break;
4262
4263 case HEROSCRIPTCSET:
4264 ret=script_hero_cset*10000;
4265 break;
4266 case LINKSCRIPFLIP:
4267 ret=script_hero_flip*10000;
4268 break;
4269
4270
4271 case LINKITEMB:
4272 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4273 15348 ret = Bwpn*10000;
4274 15348 break;
4275
4276 case LINKITEMA:
4277 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4278 15551 ret = Awpn *10000;
4279 15551 break;
4280
4281 case LINKITEMX:
4282 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4283 12319 ret = Xwpn *10000;
4284 12319 break;
4285
4286 case LINKITEMY:
4287 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4288 13864 ret = Ywpn *10000;
4289 13864 break;
4290
4291 case LINKTILEMOD:
4292 ret = Hero.getTileModifier() * 10000;
4293 break;
4294
4295 case LINKDIAG:
4296 ret=Hero.getDiagMove()?10000:0;
4297 break;
4298
4299 case LINKBIGHITBOX:
4300 ret=Hero.getBigHitbox()?10000:0;
4301 break;
4302
4303 case LINKCLIMBING:
4304 ret = Hero.getOnSideviewLadder()?10000:0;
4305 break;
4306
4307 case HEROJUMPCOUNT:
4308 ret = Hero.extra_jump_count * 10000;
4309 break;
4310
4311 case HEROPULLDIR:
4312 ret = Hero.pit_pulldir * 10000;
4313 break;
4314
4315 case HEROPULLCLK:
4316 ret = Hero.pit_pullclk * 10000;
4317 break;
4318
4319 case HEROFALLCLK:
4320 88721 ret = Hero.fallclk * 10000;
4321 88721 break;
4322
4323 case HEROFALLCMB:
4324 ret = Hero.fallCombo * 10000;
4325 break;
4326
4327 case HERODROWNCLK:
4328 ret = Hero.drownclk * 10000;
4329 break;
4330
4331 case HERODROWNCMB:
4332 ret = Hero.drownCombo * 10000;
4333 break;
4334
4335 case HEROFAKEZ:
4336 {
4337 if (get_qr(qr_SPRITEXY_IS_FLOAT))
4338 {
4339 ret = Hero.getFakeZ().getZLong();
4340 }
4341 else ret = int32_t(Hero.getFakeZ()) * 10000;
4342
4343 break;
4344 }
4345 case HEROMOVEFLAGS:
4346 {
4347 int32_t indx = ri->d[rINDEX]/10000;
4348 if(BC::checkBounds(indx, 0, 10, "Hero->MoveFlags[]") != SH::_NoError)
4349 ret = 0; //false
4350 else
4351 {
4352 //All bits, in order, of a single byte; just use bitwise
4353 ret = (Hero.moveflags & (1<<indx)) ? 10000 : 0;
4354 }
4355 break;
4356 }
4357 case HEROLIFTFLAGS:
4358 {
4359 int32_t indx = ri->d[rINDEX]/10000;
4360 if(BC::checkBounds(indx, 0, NUM_LIFTFL-1, "Hero->LiftFlags[]") != SH::_NoError)
4361 ret = 0; //false
4362 else
4363 {
4364 ret = (Hero.liftflags & (1<<indx)) ? 10000 : 0;
4365 }
4366 break;
4367 }
4368
4369 case HEROSHIELDJINX:
4370 ret = Hero.shieldjinxclk * 10000;
4371 break;
4372
4373 case HEROISWARPING:
4374 ret = Hero.is_warping ? 10000L : 0L;
4375 break;
4376
4377 case CLOCKACTIVE:
4378 ret=watch?10000:0;
4379 break;
4380
4381 case CLOCKCLK:
4382 ret=clockclk*10000;
4383 break;
4384
4385 case HERORESPAWNX:
4386 {
4387 ret = Hero.respawn_x.getZLong();
4388 break;
4389 }
4390
4391 case HERORESPAWNY:
4392 {
4393 ret = Hero.respawn_y.getZLong();
4394 break;
4395 }
4396
4397 case HERORESPAWNDMAP:
4398 {
4399 ret = Hero.respawn_dmap * 10000;
4400 break;
4401 }
4402
4403 case HERORESPAWNSCR:
4404 {
4405 ret = Hero.respawn_scr * 10000;
4406 break;
4407 }
4408
4409 case HEROSWITCHTIMER:
4410 {
4411 ret = Hero.switchhookclk * 10000;
4412 break;
4413 }
4414
4415 case HEROSWITCHMAXTIMER:
4416 {
4417 ret = Hero.switchhookmaxtime * 10000;
4418 break;
4419 }
4420
4421 case HEROIMMORTAL:
4422 {
4423 ret = Hero.immortal * 10000;
4424 break;
4425 }
4426
4427 case HEROSTANDING:
4428 {
4429 ret = Hero.isStanding(true) ? 10000 : 0;
4430 break;
4431 }
4432
4433 case HEROCOYOTETIME:
4434 {
4435 ret = Hero.coyotetime*10000;
4436 break;
4437 }
4438
4439 case HEROLIFTEDWPN:
4440 {
4441 ret = Hero.lift_wpn ? Hero.lift_wpn->getUID() : 0;
4442 break;
4443 }
4444 case HEROLIFTTIMER:
4445 {
4446 ret = Hero.liftclk * 10000;
4447 break;
4448 }
4449 case HEROLIFTMAXTIMER:
4450 {
4451 ret = Hero.tliftclk * 10000;
4452 break;
4453 }
4454 case HEROLIFTHEIGHT:
4455 {
4456 ret = Hero.liftheight.getZLong();
4457 break;
4458 }
4459 case HEROHAMMERSTATE:
4460 {
4461 ret = Hero.getHammerState() * 10000;
4462 break;
4463 }
4464
4465 ///----------------------------------------------------------------------------------------------------//
4466 //Input States
4467 case INPUTSTART:
4468 92884 ret=control_state[6]?10000:0;
4469 92884 break;
4470
4471 case INPUTMAP:
4472 4123 ret=control_state[9]?10000:0;
4473 4123 break;
4474
4475 case INPUTUP:
4476 1334115 ret=control_state[0]?10000:0;
4477 1334115 break;
4478
4479 case INPUTDOWN:
4480 847431 ret=control_state[1]?10000:0;
4481 847431 break;
4482
4483 case INPUTLEFT:
4484 1327379 ret=control_state[2]?10000:0;
4485 1327379 break;
4486
4487 case INPUTRIGHT:
4488 1369597 ret=control_state[3]?10000:0;
4489 1369597 break;
4490
4491 case INPUTA:
4492 5693944 ret=control_state[4]?10000:0;
4493 5693944 break;
4494
4495 case INPUTB:
4496 5182994 ret=control_state[5]?10000:0;
4497 5182994 break;
4498
4499 case INPUTL:
4500 3135646 ret=control_state[7]?10000:0;
4501 3135646 break;
4502
4503 case INPUTR:
4504 3131387 ret=control_state[8]?10000:0;
4505 3131387 break;
4506
4507 case INPUTEX1:
4508 119289 ret=control_state[10]?10000:0;
4509 119289 break;
4510
4511 case INPUTEX2:
4512 119580 ret=control_state[11]?10000:0;
4513 119580 break;
4514
4515 case INPUTEX3:
4516 23391 ret=control_state[12]?10000:0;
4517 23391 break;
4518
4519 case INPUTEX4:
4520 23391 ret=control_state[13]?10000:0;
4521 23391 break;
4522
4523 case INPUTAXISUP:
4524 ret=control_state[14]?10000:0;
4525 break;
4526
4527 case INPUTAXISDOWN:
4528 ret=control_state[15]?10000:0;
4529 break;
4530
4531 case INPUTAXISLEFT:
4532 ret=control_state[16]?10000:0;
4533 break;
4534
4535 case INPUTAXISRIGHT:
4536 ret=control_state[17]?10000:0;
4537 break;
4538
4539 case INPUTMOUSEX:
4540 {
4541 766680 ret=get_mouse_state(0)*10000;
4542 766680 break;
4543 }
4544
4545 case INPUTMOUSEY:
4546 {
4547 766680 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
4548
3/4
✓ Branch 0 taken 17451 times.
✓ Branch 1 taken 749229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 749229 times.
766680 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset : (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
4549 766680 ret=((get_mouse_state(1)-tempoffset))*10000;
4550 766680 break;
4551 }
4552
4553 case INPUTMOUSEZ:
4554 ret=(get_mouse_state(2))*10000;
4555 break;
4556
4557 case INPUTMOUSEB:
4558 1041016 ret=(get_mouse_state(3))*10000;
4559 1041016 break;
4560
4561 case INPUTPRESSSTART:
4562 728101 ret=button_press[6]?10000:0;
4563 728101 break;
4564
4565 case INPUTPRESSMAP:
4566 276546 ret=button_press[9]?10000:0;
4567 276546 break;
4568
4569 case INPUTPRESSUP:
4570 775420 ret=button_press[0]?10000:0;
4571 775420 break;
4572
4573 case INPUTPRESSDOWN:
4574 715403 ret=button_press[1]?10000:0;
4575 715403 break;
4576
4577 case INPUTPRESSLEFT:
4578 556980 ret=button_press[2]?10000:0;
4579 556980 break;
4580
4581 case INPUTPRESSRIGHT:
4582 514803 ret=button_press[3]?10000:0;
4583 514803 break;
4584
4585 case INPUTPRESSA:
4586 1875584 ret=button_press[4]?10000:0;
4587 1875584 break;
4588
4589 case INPUTPRESSB:
4590 1726419 ret=button_press[5]?10000:0;
4591 1726419 break;
4592
4593 case INPUTPRESSL:
4594 1861217 ret=button_press[7]?10000:0;
4595 1861217 break;
4596
4597 case INPUTPRESSR:
4598 1691656 ret=button_press[8]?10000:0;
4599 1691656 break;
4600
4601 case INPUTPRESSEX1:
4602 873882 ret=button_press[10]?10000:0;
4603 873882 break;
4604
4605 case INPUTPRESSEX2:
4606 873847 ret=button_press[11]?10000:0;
4607 873847 break;
4608
4609 case INPUTPRESSEX3:
4610 541201 ret=button_press[12]?10000:0;
4611 541201 break;
4612
4613 case INPUTPRESSEX4:
4614 541201 ret=button_press[13]?10000:0;
4615 541201 break;
4616
4617 case INPUTPRESSAXISUP:
4618 ret=button_press[14]?10000:0;
4619 break;
4620
4621 case INPUTPRESSAXISDOWN:
4622 ret=button_press[15]?10000:0;
4623 break;
4624
4625 case INPUTPRESSAXISLEFT:
4626 ret=button_press[16]?10000:0;
4627 break;
4628
4629 case INPUTPRESSAXISRIGHT:
4630 ret=button_press[17]?10000:0;
4631 break;
4632
4633 case FFRULE:
4634 {
4635 int32_t ruleid = vbound((ri->d[rINDEX]/10000),0,qr_MAX);
4636 ret = get_qr(ruleid)?10000:0;
4637 }
4638 break;
4639
4640 case BUTTONPRESS:
4641 // DUkey, DDkey, DLkey, DRkey, Akey, Bkey, Skey, Lkey, Rkey, Pkey, Exkey1, Exkey2, Exkey3, Exkey4 };
4642 {
4643 //Read-only
4644 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
4645 ret = button_press[button]?10000:0;
4646 }
4647 break;
4648
4649 case BUTTONINPUT:
4650 {
4651 //Read-only
4652 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
4653 ret=control_state[button]?10000:0;
4654 }
4655 break;
4656
4657 case BUTTONHELD:
4658 {
4659 //Read-only
4660 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
4661 ret = button_hold[button]?10000:0;
4662 }
4663 break;
4664
4665 case RAWKEY:
4666 { //Game->KeyPressed[], read-only
4667 //if ( !keypressed() ) break; //Don;t return values set by setting Hero->Input/Press
4668 //hmm...no, this won;t return properly for modifier keys.
4669 int32_t keyid = ri->d[rINDEX]/10000;
4670 //key = vbound(key,0,n);
4671 bool pressed = key_current_frame[keyid] != 0;
4672 ret = pressed?10000:0;
4673 }
4674 break;
4675
4676 case KEYINPUT:
4677 {
4678 1121 ret = KeyInput[ri->d[rINDEX]/10000] ? 10000 : 0;
4679 1121 break;
4680 }
4681 case KEYPRESS:
4682 {
4683 6213 ret = KeyPress[ri->d[rINDEX]/10000] ? 10000 : 0;
4684 6213 break;
4685 }
4686
4687 case KEYMODIFIERS:
4688 {
4689 ret = (key_shifts*10000);
4690 break;
4691 }
4692
4693 case KEYBINDINGS:
4694 {
4695 int32_t keyid = ri->d[rINDEX]/10000;
4696 switch(keyid)
4697 {
4698 case 0: ret = DUkey * 10000; break;
4699 case 1: ret = DDkey * 10000; break;
4700 case 2: ret = DLkey * 10000; break;
4701 case 3: ret = DRkey * 10000; break;
4702 case 4: ret = Akey * 10000; break;
4703 case 5: ret = Bkey * 10000; break;
4704 case 6: ret = Skey * 10000; break;
4705 case 7: ret = Lkey * 10000; break;
4706 case 8: ret = Rkey * 10000; break;
4707 case 9: ret = Pkey * 10000; /*map*/ break;
4708 case 10: ret = Exkey1 * 10000; break;
4709 case 11: ret = Exkey2 * 10000; break;
4710 case 12: ret = Exkey3 * 10000; break;
4711 case 13: ret = Exkey4 * 10000; break;
4712
4713 default: { Z_scripterrlog("Invalid index [%d] passed to Input->KeyBindings[]\n", keyid); ret = 0; break; }
4714 }
4715 break;
4716 }
4717
4718 case READKEY:
4719 {
4720 //Game->ReadKey(int32_t key), also clears it.
4721 int32_t keyid = ri->d[rINDEX]/10000;
4722 bool pressed = zc_readkey(keyid, true);
4723 ret = pressed?10000:0;
4724 }
4725 break;
4726
4727 case DISABLEKEY:
4728 {
4729 //Input->DisableKey(int32_t key)
4730 int32_t keyid = ri->d[rINDEX]/10000;
4731 ret = disabledKeys[keyid]?10000:0;
4732 break;
4733 }
4734
4735 case DISABLEBUTTON:
4736 {
4737 //Input->DisableButton(int32_t cb)
4738 int32_t cbid = ri->d[rINDEX]/10000;
4739 ret = disable_control[cbid]?10000:0;
4740 break;
4741 }
4742
4743 case JOYPADPRESS:
4744 {
4745 //Checks if a press is from the joypad, not keyboard.
4746 int32_t button = ri->d[rINDEX]/10000;
4747 ret = joybtn(button)?10000:0;
4748 }
4749 break;
4750
4751
4752 case MOUSEARR:
4753 {
4754 468 int32_t indx = (ri->d[rINDEX]/10000);
4755 int32_t rv;
4756
2/7
✗ Branch 0 not taken.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
468 switch (indx)
4757 {
4758 case 0: //MouseX
4759 {
4760 234 rv=get_mouse_state(0)*10000;
4761 234 break;
4762 }
4763 case 1: //MouseY
4764 {
4765 234 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
4766
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 234 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 234 times.
234 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset : (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
4767 234 int32_t topOffset= (112-tempoffset);
4768 234 rv=(get_mouse_state(1)-topOffset)*10000;
4769 234 break;
4770 }
4771 case 2: //MouseZ
4772 {
4773 rv=(get_mouse_state(2))*10000;
4774 break;
4775 }
4776 case 3: //Left Click
4777 {
4778 rv=((get_mouse_state(3)&0x1))*10000;
4779 break;
4780 }
4781 case 4: //Right Click
4782 {
4783 rv=((get_mouse_state(3)&0x2))*10000;
4784 break;
4785 }
4786 case 5: //Middle Click
4787 {
4788 rv=((get_mouse_state(3)&0x4))*10000;
4789 break;
4790 }
4791 default:
4792 {
4793 Z_scripterrlog("Invalid index passed to Input->Mouse[]: %d\n", indx);
4794 rv = -10000;
4795 break;
4796 }
4797 }
4798
4799 //bool pressed = key[keyid] != 0;
4800 //ret = pressed?10000:0;
4801 468 ret = rv;
4802 }
4803 468 break;
4804
4805 ///----------------------------------------------------------------------------------------------------//
4806 //Item Variables
4807 case ITEMSCALE:
4808 if ( get_qr(qr_OLDSPRITEDRAWS) )
4809 {
4810 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
4811 "item->Scale");
4812 ret = -1; break;
4813 }
4814 if(0!=(s=checkItem(ri->itemref)))
4815 {
4816 ret=((int32_t)((item*)(s))->scale)*100.0;
4817 }
4818 break;
4819
4820 case ITEMX:
4821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5848 times.
5848 if(0!=(s=checkItem(ri->itemref)))
4822 {
4823
2/2
✓ Branch 0 taken 2722 times.
✓ Branch 1 taken 3126 times.
5848 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4824 {
4825 2722 ret=(((item*)(s))->x).getZLong();
4826 2722 }
4827 3126 else ret=((int32_t)((item*)(s))->x)*10000;
4828 5848 }
4829 5848 break;
4830
4831 case ITEMSPRITESCRIPT:
4832 if(0!=(s=checkItem(ri->itemref)))
4833 {
4834 ret=((int32_t)((item*)(s))->script)*10000;
4835 }
4836 break;
4837
4838 case ITEMSPRITEINITD:
4839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(0!=(s=checkItem(ri->itemref)))
4840 {
4841 24 int32_t a = vbound(ri->d[rINDEX]/10000,0,7);
4842 24 ret=((int32_t)((item*)(s))->initD[a]);
4843 24 }
4844 24 break;
4845
4846 case ITEMFAMILY:
4847 if(0!=(s=checkItem(ri->itemref)))
4848 {
4849 ret=((int32_t)((item*)(s))->family)*10000;
4850 }
4851 break;
4852
4853 case ITEMLEVEL:
4854 if(0!=(s=checkItem(ri->itemref)))
4855 {
4856 ret=((int32_t)((item*)(s))->lvl)*10000;
4857 }
4858 break;
4859
4860 case SPRITEMAXITEM:
4861 {
4862 //No bounds check, as this is a universal function and works from NULL pointers!
4863 ret = items.getMax() * 10000;
4864 break;
4865 }
4866
4867 case ITEMSCRIPTUID:
4868 if(0!=(s=checkItem(ri->itemref)))
4869 {
4870 ret=((int32_t)((item*)(s))->script_UID); //Literal, not *10000
4871 }
4872 break;
4873
4874 case ITEMY:
4875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4206 times.
4206 if(0!=(s=checkItem(ri->itemref)))
4876 {
4877
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 3126 times.
4206 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4878 {
4879 1080 ret=(((item*)(s))->y).getZLong();
4880 1080 }
4881 else
4882 3126 ret=((int32_t)((item*)(s))->y)*10000;
4883 4206 }
4884 4206 break;
4885
4886 case ITEMZ:
4887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5084 times.
5084 if(0!=(s=checkItem(ri->itemref)))
4888 {
4889
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5082 times.
5084 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4890 {
4891 2 ret=(((item*)(s))->z).getZLong();
4892 2 }
4893 else
4894 5082 ret=((int32_t)((item*)(s))->z)*10000;
4895 5084 }
4896 5084 break;
4897
4898 case ITEMJUMP:
4899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(0!=(s=checkItem(ri->itemref)))
4900 {
4901 114 ret = ((item*)(s))->fall.getZLong() / -100;
4902
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
4903 114 }
4904 114 break;
4905
4906 case ITEMFAKEJUMP:
4907 if(0!=(s=checkItem(ri->itemref)))
4908 {
4909 ret = ((item*)(s))->fakefall.getZLong() / -100;
4910 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
4911 }
4912 break;
4913
4914 case ITEMDRAWTYPE:
4915 if(0!=(s=checkItem(ri->itemref)))
4916 {
4917 ret=((item*)(s))->drawstyle*10000;
4918 }
4919 break;
4920
4921 case ITEMGRAVITY:
4922 if(0!=(s=checkItem(ri->itemref)))
4923 {
4924 ret=((((item*)(s))->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0);
4925 }
4926 break;
4927
4928 case ITEMID:
4929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117090 times.
117090 if(0!=(s=checkItem(ri->itemref)))
4930 {
4931 117090 ret=((item*)(s))->id*10000;
4932 117090 }
4933 117090 break;
4934
4935 case ITEMTILE:
4936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7933 times.
7933 if(0!=(s=checkItem(ri->itemref)))
4937 {
4938 7933 ret=((item*)(s))->tile*10000;
4939 7933 }
4940 7933 break;
4941
4942 case ITEMSCRIPTTILE:
4943 if(0!=(s=checkItem(ri->itemref)))
4944 {
4945 ret=((item*)(s))->scripttile*10000;
4946 }
4947 break;
4948
4949 case ITEMSCRIPTFLIP:
4950 if(0!=(s=checkItem(ri->itemref)))
4951 {
4952 ret=((item*)(s))->scriptflip*10000;
4953 }
4954 break;
4955
4956 case ITEMPSTRING:
4957 if(0!=(s=checkItem(ri->itemref)))
4958 {
4959 ret=((item*)(s))->pstring*10000;
4960 }
4961 break;
4962 case ITEMPSTRINGFLAGS:
4963 if(0!=(s=checkItem(ri->itemref)))
4964 {
4965 ret=((item*)(s))->pickup_string_flags*10000;
4966 }
4967 break;
4968 case ITEMOVERRIDEFLAGS:
4969 ret=0;
4970 break;
4971
4972 case ITEMOTILE:
4973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(0!=(s=checkItem(ri->itemref)))
4974 {
4975 18 ret=((item*)(s))->o_tile*10000;
4976 18 }
4977 18 break;
4978
4979 case ITEMCSET:
4980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7933 times.
7933 if(0!=(s=checkItem(ri->itemref)))
4981 {
4982 7933 ret=(((item*)(s))->o_cset&15)*10000;
4983 7933 }
4984 7933 break;
4985
4986 case ITEMFLASHCSET:
4987 if(0!=(s=checkItem(ri->itemref)))
4988 {
4989 ret=(((item*)(s))->o_cset>>4)*10000;
4990 }
4991 break;
4992
4993 case ITEMFRAMES:
4994 if(0!=(s=checkItem(ri->itemref)))
4995 {
4996 ret=((item*)(s))->frames*10000;
4997 }
4998 break;
4999
5000 case ITEMFRAME:
5001 if(0!=(s=checkItem(ri->itemref)))
5002 {
5003 ret=((item*)(s))->aframe*10000;
5004 }
5005 break;
5006
5007 case ITEMACLK:
5008 if(0!=(s=checkItem(ri->itemref)))
5009 {
5010 ret=((item*)(s))->aclk*10000;
5011 }
5012 break;
5013
5014 case ITEMASPEED:
5015 if(0!=(s=checkItem(ri->itemref)))
5016 {
5017 ret=((item*)(s))->o_speed*10000;
5018 }
5019 break;
5020
5021 case ITEMDELAY:
5022 if(0!=(s=checkItem(ri->itemref)))
5023 {
5024 ret=((item*)(s))->o_delay*10000;
5025 }
5026 break;
5027
5028 case ITEMFLIP:
5029 if(0!=(s=checkItem(ri->itemref)))
5030 {
5031 ret=((item*)(s))->flip*10000;
5032 }
5033 break;
5034
5035 case ITEMFLASH:
5036 if(0!=(s=checkItem(ri->itemref)))
5037 {
5038 ret=((item*)(s))->flash*10000;
5039 }
5040 break;
5041
5042 case ITEMHXOFS:
5043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2552 times.
2552 if(0!=(s=checkItem(ri->itemref)))
5044 {
5045 2552 ret=(((item*)(s))->hxofs)*10000;
5046 2552 }
5047 2552 break;
5048
5049 case ITEMROTATION:
5050 if ( get_qr(qr_OLDSPRITEDRAWS) )
5051 {
5052 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
5053 "item->Rotation");
5054 ret = -1; break;
5055 }
5056 if(0!=(s=checkItem(ri->itemref)))
5057 {
5058 ret=(((item*)(s))->rotation)*10000;
5059 }
5060 break;
5061
5062 case ITEMHYOFS:
5063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2552 times.
2552 if(0!=(s=checkItem(ri->itemref)))
5064 {
5065 2552 ret=(((item*)(s))->hyofs)*10000;
5066 2552 }
5067 2552 break;
5068
5069 case ITEMXOFS:
5070
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(0!=(s=checkItem(ri->itemref)))
5071 {
5072 6 ret=((int32_t)(((item*)(s))->xofs))*10000;
5073 6 }
5074 6 break;
5075
5076 case ITEMYOFS:
5077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if(0!=(s=checkItem(ri->itemref)))
5078 {
5079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 ret=((int32_t)(((item*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))*10000;
5080 334 }
5081 334 break;
5082
5083 case ITEMSHADOWXOFS:
5084 if(0!=(s=checkItem(ri->itemref)))
5085 {
5086 ret=((int32_t)(((item*)(s))->shadowyofs))*10000;
5087 }
5088 break;
5089
5090 case ITEMSHADOWYOFS:
5091 if(0!=(s=checkItem(ri->itemref)))
5092 {
5093 ret=((int32_t)(((item*)(s))->shadowxofs))*10000;
5094 }
5095 break;
5096
5097
5098 case ITEMZOFS:
5099 if(0!=(s=checkItem(ri->itemref)))
5100 {
5101 ret=((int32_t)(((item*)(s))->zofs))*10000;
5102 }
5103 break;
5104
5105 case ITEMHXSZ:
5106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2552 times.
2552 if(0!=(s=checkItem(ri->itemref)))
5107 {
5108 2552 ret=(((item*)(s))->hit_width)*10000;
5109 2552 }
5110 2552 break;
5111
5112 case ITEMHYSZ:
5113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2552 times.
2552 if(0!=(s=checkItem(ri->itemref)))
5114 {
5115 2552 ret=(((item*)(s))->hit_height)*10000;
5116 2552 }
5117 2552 break;
5118
5119 case ITEMHZSZ:
5120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2542 times.
2542 if(0!=(s=checkItem(ri->itemref)))
5121 {
5122 2542 ret=(((item*)(s))->hzsz)*10000;
5123 2542 }
5124 2542 break;
5125
5126 case ITEMTXSZ:
5127
1/2
✓ Branch 0 taken 1300 times.
✗ Branch 1 not taken.
1300 if(0!=(s=checkItem(ri->itemref)))
5128 {
5129 1300 ret=(((item*)(s))->txsz)*10000;
5130 1300 }
5131 1300 break;
5132
5133 case ITEMTYSZ:
5134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1300 times.
1300 if(0!=(s=checkItem(ri->itemref)))
5135 {
5136 1300 ret=(((item*)(s))->tysz)*10000;
5137 1300 }
5138 1300 break;
5139
5140 case ITEMCOUNT:
5141 685905 ret=(items.Count())*10000;
5142 685905 break;
5143
5144 case GETRENDERTARGET:
5145 ret=(zscriptDrawingRenderTarget->GetCurrentRenderTarget())*10000;
5146 break;
5147
5148 case ITEMEXTEND:
5149 if(0!=(s=checkItem(ri->itemref)))
5150 {
5151 ret=((item*)(s))->extend*10000;
5152 }
5153 break;
5154
5155 case ITEMPICKUP:
5156
1/2
✓ Branch 0 taken 19906 times.
✗ Branch 1 not taken.
19906 if(0!=(s=checkItem(ri->itemref)))
5157 {
5158 19906 ret=((item*)(s))->pickup*10000;
5159 19906 }
5160 19906 break;
5161
5162 case ITEMMISCD:
5163
1/2
✓ Branch 0 taken 108294 times.
✗ Branch 1 not taken.
108294 if(0!=(s=checkItem(ri->itemref)))
5164 {
5165 108294 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
5166 108294 ret=(((item*)(s))->miscellaneous[a]);
5167 108294 }
5168 108294 break;
5169
5170 case ITEMFALLCLK:
5171 if(0!=(s=checkItem(ri->itemref)))
5172 {
5173 ret = ((item*)(s))->fallclk * 10000;
5174 }
5175 break;
5176
5177 case ITEMFALLCMB:
5178 if(0!=(s=checkItem(ri->itemref)))
5179 {
5180 ret = ((item*)(s))->fallCombo * 10000;
5181 }
5182 break;
5183
5184 case ITEMDROWNCLK:
5185 if(0!=(s=checkItem(ri->itemref)))
5186 {
5187 ret = ((item*)(s))->drownclk * 10000;
5188 }
5189 break;
5190
5191 case ITEMDROWNCMB:
5192 if(0!=(s=checkItem(ri->itemref)))
5193 {
5194 ret = ((item*)(s))->drownCombo * 10000;
5195 }
5196 break;
5197
5198 case ITEMFAKEZ:
5199 if(0!=(s=checkItem(ri->itemref)))
5200 {
5201 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
5202 {
5203 ret=(((item*)(s))->fakez).getZLong();
5204 }
5205 else
5206 ret=((int32_t)((item*)(s))->fakez)*10000;
5207 }
5208 break;
5209
5210
5211 case ITEMMOVEFLAGS:
5212 {
5213 if(0!=(s=checkItem(ri->itemref)))
5214 {
5215 int32_t indx = ri->d[rINDEX]/10000;
5216 if(BC::checkBounds(indx, 0, 10, "itemsprite->MoveFlags[]") != SH::_NoError)
5217 ret = 0; //false
5218 else
5219 {
5220 //All bits, in order, of a single byte; just use bitwise
5221 ret = (((item*)(s))->moveflags & (1<<indx)) ? 10000 : 0;
5222 }
5223 }
5224 break;
5225 }
5226
5227 case ITEMGLOWRAD:
5228 if(0!=(s=checkItem(ri->itemref)))
5229 {
5230 ret = ((item*)(s))->glowRad * 10000;
5231 }
5232 break;
5233
5234 case ITEMGLOWSHP:
5235 if(0!=(s=checkItem(ri->itemref)))
5236 {
5237 ret = ((item*)(s))->glowShape * 10000;
5238 }
5239 break;
5240
5241 case ITEMDIR:
5242 if(0!=(s=checkItem(ri->itemref)))
5243 {
5244 ret = ((item*)(s))->dir * 10000;
5245 }
5246 break;
5247
5248 case ITEMENGINEANIMATE:
5249 if(0!=(s=checkItem(ri->itemref)))
5250 {
5251 ret = int32_t(((item*)(s))->do_animation) * 10000;
5252 }
5253 break;
5254
5255 case ITEMSHADOWSPR:
5256 if(0!=(s=checkItem(ri->itemref)))
5257 {
5258 ret = int32_t(((item*)(s))->spr_shadow) * 10000;
5259 }
5260 break;
5261 case ITEMDROPPEDBY:
5262 if(0!=(s=checkItem(ri->itemref)))
5263 {
5264 ret = int32_t(((item*)(s))->from_dropset) * 10000;
5265 }
5266 break;
5267 case ITMSWHOOKED:
5268 if(0!=(s=checkItem(ri->itemref)))
5269 {
5270 ret = s->switch_hooked ? 10000 : 0;
5271 }
5272 break;
5273 case ITEMFORCEGRAB:
5274 if(0!=(s=checkItem(ri->itemref)))
5275 {
5276 ret = ((item*)s)->get_forcegrab() ? 10000 : 0;
5277 }
5278 break;
5279
5280 ///----------------------------------------------------------------------------------------------------//
5281 //Itemdata Variables
5282
5283
5284 case IDATAUSEWPN:
5285 if(unsigned(ri->idata) >= MAXITEMS)
5286 {
5287 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5288 ret = -10000;
5289 break;
5290 }
5291 ret=(itemsbuf[ri->idata].useweapon)*10000;
5292 break;
5293 case IDATAUSEDEF:
5294 if(unsigned(ri->idata) >= MAXITEMS)
5295 {
5296 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5297 ret = -10000;
5298 break;
5299 }
5300 ret=(itemsbuf[ri->idata].usedefence)*10000;
5301 break;
5302 case IDATAWRANGE:
5303 if(unsigned(ri->idata) >= MAXITEMS)
5304 {
5305 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5306 ret = -10000;
5307 break;
5308 }
5309 ret=(itemsbuf[ri->idata].weaprange)*10000;
5310 break;
5311 case IDATAMAGICTIMER:
5312 if(unsigned(ri->idata) >= MAXITEMS)
5313 {
5314 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5315 ret = -10000;
5316 break;
5317 }
5318 ret=(itemsbuf[ri->idata].magiccosttimer[0])*10000;
5319 break;
5320 case IDATAMAGICTIMER2:
5321 if(unsigned(ri->idata) >= MAXITEMS)
5322 {
5323 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5324 ret = -10000;
5325 break;
5326 }
5327 ret=(itemsbuf[ri->idata].magiccosttimer[1])*10000;
5328 break;
5329 case IDATAUSEMVT:
5330 {
5331 if(unsigned(ri->idata) >= MAXITEMS)
5332 {
5333 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5334 ret = -10000;
5335 break;
5336 }
5337 int32_t a = vbound((ri->d[rINDEX] / 10000),0,(ITEM_MOVEMENT_PATTERNS-1));
5338 ret=(itemsbuf[ri->idata].weap_pattern[a])*10000;
5339 }
5340 break;
5341
5342 case IDATADURATION:
5343 if(unsigned(ri->idata) >= MAXITEMS)
5344 {
5345 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5346 ret = -10000;
5347 break;
5348 }
5349 ret=(itemsbuf[ri->idata].weapduration)*10000;
5350 break;
5351
5352 case IDATADUPLICATES:
5353 if(unsigned(ri->idata) >= MAXITEMS)
5354 {
5355 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5356 ret = -10000;
5357 break;
5358 }
5359 ret=(itemsbuf[ri->idata].duplicates)*10000;
5360 break;
5361 case IDATADRAWLAYER:
5362 if(unsigned(ri->idata) >= MAXITEMS)
5363 {
5364 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5365 ret = -10000;
5366 break;
5367 }
5368 ret=(itemsbuf[ri->idata].drawlayer)*10000;
5369 break;
5370 case IDATACOLLECTFLAGS:
5371 if(unsigned(ri->idata) >= MAXITEMS)
5372 {
5373 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5374 ret = 0;
5375 break;
5376 }
5377 ret=(itemsbuf[ri->idata].collectflags)*10000;
5378 break;
5379 case IDATAWEAPONSCRIPT:
5380 if(unsigned(ri->idata) >= MAXITEMS)
5381 {
5382 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5383 ret = -10000;
5384 break;
5385 }
5386 ret=(itemsbuf[ri->idata].weaponscript)*10000;
5387 break;
5388 case IDATAMISCD:
5389 {
5390 if(unsigned(ri->idata) >= MAXITEMS)
5391 {
5392 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5393 ret = -10000;
5394 break;
5395 }
5396 int32_t a = vbound((ri->d[rINDEX] / 10000),0,31);
5397 ret=(itemsbuf[ri->idata].wpn_misc_d[a])*10000;
5398 }
5399 break;
5400 case IDATAWPNINITD:
5401 {
5402 if(unsigned(ri->idata) >= MAXITEMS)
5403 {
5404 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5405 ret = -10000;
5406 break;
5407 }
5408 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
5409 ret=(itemsbuf[ri->idata].weap_initiald[a]);
5410 }
5411 break;
5412 case IDATAWEAPHXOFS:
5413 if(unsigned(ri->idata) >= MAXITEMS)
5414 {
5415 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5416 ret = -10000;
5417 break;
5418 }
5419 ret=(itemsbuf[ri->idata].weap_hxofs)*10000;
5420 break;
5421 case IDATAWEAPHYOFS:
5422 if(unsigned(ri->idata) >= MAXITEMS)
5423 {
5424 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5425 ret = -10000;
5426 break;
5427 }
5428 ret=(itemsbuf[ri->idata].weap_hyofs)*10000;
5429 break;
5430 case IDATAWEAPHXSZ:
5431 if(unsigned(ri->idata) >= MAXITEMS)
5432 {
5433 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5434 ret = -10000;
5435 break;
5436 }
5437 ret=(itemsbuf[ri->idata].weap_hxsz)*10000;
5438 break;
5439 case IDATAWEAPHYSZ:
5440 if(unsigned(ri->idata) >= MAXITEMS)
5441 {
5442 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5443 ret = -10000;
5444 break;
5445 }
5446 ret=(itemsbuf[ri->idata].weap_hysz)*10000;
5447 break;
5448 case IDATAWEAPHZSZ:
5449 if(unsigned(ri->idata) >= MAXITEMS)
5450 {
5451 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5452 ret = -10000;
5453 break;
5454 }
5455 ret=(itemsbuf[ri->idata].weap_hzsz)*10000;
5456 break;
5457 case IDATAWEAPXOFS:
5458 if(unsigned(ri->idata) >= MAXITEMS)
5459 {
5460 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5461 ret = -10000;
5462 break;
5463 }
5464 ret=(itemsbuf[ri->idata].weap_xofs)*10000;
5465 break;
5466 case IDATAWEAPYOFS:
5467 if(unsigned(ri->idata) >= MAXITEMS)
5468 {
5469 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5470 ret = -10000;
5471 break;
5472 }
5473 ret=(itemsbuf[ri->idata].weap_yofs)*10000;
5474 break;
5475 case IDATAHXOFS:
5476 if(unsigned(ri->idata) >= MAXITEMS)
5477 {
5478 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5479 ret = -10000;
5480 break;
5481 }
5482 ret=(itemsbuf[ri->idata].hxofs)*10000;
5483 break;
5484 case IDATAHYOFS:
5485 if(unsigned(ri->idata) >= MAXITEMS)
5486 {
5487 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5488 ret = -10000;
5489 break;
5490 }
5491 ret=(itemsbuf[ri->idata].hyofs)*10000;
5492 break;
5493 case IDATAHXSZ:
5494 if(unsigned(ri->idata) >= MAXITEMS)
5495 {
5496 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5497 ret = -10000;
5498 break;
5499 }
5500 ret=(itemsbuf[ri->idata].hxsz)*10000;
5501 break;
5502 case IDATAHYSZ:
5503 if(unsigned(ri->idata) >= MAXITEMS)
5504 {
5505 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5506 ret = -10000;
5507 break;
5508 }
5509 ret=(itemsbuf[ri->idata].hysz)*10000;
5510 break;
5511 case IDATAHZSZ:
5512 if(unsigned(ri->idata) >= MAXITEMS)
5513 {
5514 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5515 ret = -10000;
5516 break;
5517 }
5518 ret=(itemsbuf[ri->idata].hzsz)*10000;
5519 break;
5520 case IDATADXOFS:
5521 if(unsigned(ri->idata) >= MAXITEMS)
5522 {
5523 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5524 ret = -10000;
5525 break;
5526 }
5527 ret=(itemsbuf[ri->idata].xofs)*10000;
5528 break;
5529 case IDATADYOFS:
5530 if(unsigned(ri->idata) >= MAXITEMS)
5531 {
5532 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5533 ret = -10000;
5534 break;
5535 }
5536 ret=(itemsbuf[ri->idata].yofs)*10000;
5537 break;
5538 case IDATATILEW:
5539 if(unsigned(ri->idata) >= MAXITEMS)
5540 {
5541 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5542 ret = -10000;
5543 break;
5544 }
5545 ret=(itemsbuf[ri->idata].tilew)*10000;
5546 break;
5547 case IDATATILEH:
5548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(unsigned(ri->idata) >= MAXITEMS)
5549 {
5550 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5551 ret = -10000;
5552 break;
5553 }
5554 53 ret=(itemsbuf[ri->idata].tileh)*10000;
5555 53 break;
5556 case IDATAPICKUP:
5557 if(unsigned(ri->idata) >= MAXITEMS)
5558 {
5559 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5560 ret = -10000;
5561 break;
5562 }
5563 ret=(itemsbuf[ri->idata].pickup)*10000;
5564 break;
5565 case IDATAOVERRIDEFL:
5566 if(unsigned(ri->idata) >= MAXITEMS)
5567 {
5568 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5569 ret = 0;
5570 break;
5571 }
5572 ret=(itemsbuf[ri->idata].overrideFLAGS)*10000;
5573 break;
5574
5575 case IDATATILEWWEAP:
5576 if(unsigned(ri->idata) >= MAXITEMS)
5577 {
5578 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5579 ret = -10000;
5580 break;
5581 }
5582 ret=(itemsbuf[ri->idata].weap_tilew)*10000;
5583 break;
5584 case IDATATILEHWEAP:
5585 if(unsigned(ri->idata) >= MAXITEMS)
5586 {
5587 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5588 ret = -10000;
5589 break;
5590 }
5591 ret=(itemsbuf[ri->idata].weap_tileh)*10000;
5592 break;
5593 case IDATAOVERRIDEFLWEAP:
5594 if(unsigned(ri->idata) >= MAXITEMS)
5595 {
5596 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5597 ret = 0;
5598 break;
5599 }
5600 ret=(itemsbuf[ri->idata].weapoverrideFLAGS)*10000;
5601 break;
5602
5603 case IDATAFAMILY:
5604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901 times.
901 if(unsigned(ri->idata) >= MAXITEMS)
5605 {
5606 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5607 ret = -10000;
5608 break;
5609 }
5610 901 ret=(itemsbuf[ri->idata].family)*10000;
5611 901 break;
5612
5613 case IDATALEVEL:
5614 if(unsigned(ri->idata) >= MAXITEMS)
5615 {
5616 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5617 ret = -10000;
5618 break;
5619 }
5620 ret=(itemsbuf[ri->idata].fam_type)*10000;
5621 break;
5622
5623 case IDATAKEEP:
5624 ret = item_flag(ITEM_GAMEDATA);
5625 break;
5626
5627 case IDATAAMOUNT:
5628 {
5629 if(unsigned(ri->idata) >= MAXITEMS)
5630 {
5631 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5632 ret = -10000;
5633 break;
5634 }
5635 int32_t v = itemsbuf[ri->idata].amount;
5636 ret = ((v&0x4000)?-1:1)*(v & 0x3FFF)*10000;
5637 break;
5638 }
5639 case IDATAGRADUAL:
5640 {
5641 if(unsigned(ri->idata) >= MAXITEMS)
5642 {
5643 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5644 ret = -10000;
5645 break;
5646 }
5647 ret = (itemsbuf[ri->idata].amount&0x8000) ? 10000 : 0;
5648 break;
5649 }
5650 case IDATACONSTSCRIPT:
5651 ret = item_flag(ITEM_PASSIVESCRIPT);
5652 break;
5653 case IDATASSWIMDISABLED:
5654 ret = item_flag(ITEM_SIDESWIM_DISABLED);
5655 break;
5656 case IDATABUNNYABLE:
5657 ret = item_flag(ITEM_BUNNY_ENABLED);
5658 break;
5659 case IDATAJINXIMMUNE:
5660 ret = item_flag(ITEM_JINX_IMMUNE);
5661 break;
5662 case IDATAJINXSWAP:
5663 ret = item_flag(ITEM_FLIP_JINX);
5664 break;
5665
5666 case IDATASETMAX:
5667 if(unsigned(ri->idata) >= MAXITEMS)
5668 {
5669 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5670 ret = -10000;
5671 break;
5672 }
5673 ret=(itemsbuf[ri->idata].setmax)*10000;
5674 break;
5675
5676 case IDATAMAX:
5677 if(unsigned(ri->idata) >= MAXITEMS)
5678 {
5679 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5680 ret = -10000;
5681 break;
5682 }
5683 ret=(itemsbuf[ri->idata].max)*10000;
5684 break;
5685
5686 case IDATACOUNTER:
5687 if(unsigned(ri->idata) >= MAXITEMS)
5688 {
5689 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5690 ret = -10000;
5691 break;
5692 }
5693 ret=(itemsbuf[ri->idata].count)*10000;
5694 break;
5695
5696 case IDATAPSOUND:
5697 if(unsigned(ri->idata) >= MAXITEMS)
5698 {
5699 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5700 ret = -10000;
5701 break;
5702 }
5703 ret=(itemsbuf[ri->idata].playsound)*10000;
5704 break;
5705 case IDATAUSESOUND:
5706 if(unsigned(ri->idata) >= MAXITEMS)
5707 {
5708 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5709 ret = -10000;
5710 break;
5711 }
5712 ret=(itemsbuf[ri->idata].usesound)*10000;
5713 break;
5714
5715 case IDATAUSESOUND2:
5716 if(unsigned(ri->idata) >= MAXITEMS)
5717 {
5718 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5719 ret = -10000;
5720 break;
5721 }
5722 ret=(itemsbuf[ri->idata].usesound2)*10000;
5723 break;
5724
5725 case IDATAPOWER:
5726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(unsigned(ri->idata) >= MAXITEMS)
5727 {
5728 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5729 ret = -10000;
5730 break;
5731 }
5732 140 ret=(itemsbuf[ri->idata].power)*10000;
5733 140 break;
5734
5735 //Get the ID of an item.
5736 case IDATAID:
5737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1765 times.
1765 if(unsigned(ri->idata) >= MAXITEMS)
5738 {
5739 //Don't error here //Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5740 ret = -10000;
5741 break;
5742 }
5743 1765 ret=ri->idata*10000;
5744 1765 break;
5745
5746 //Get the script assigned to an item (active)
5747 case IDATASCRIPT:
5748 if(unsigned(ri->idata) >= MAXITEMS)
5749 {
5750 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5751 ret = -10000;
5752 break;
5753 }
5754 ret=(itemsbuf[ri->idata].script)*10000;
5755 break;
5756 case IDATASPRSCRIPT:
5757 if(unsigned(ri->idata) >= MAXITEMS)
5758 {
5759 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5760 ret = -10000;
5761 break;
5762 }
5763 ret=(itemsbuf[ri->idata].sprite_script)*10000;
5764 break;
5765 //Get the ->Attributes[] of an item
5766 case IDATAATTRIB:
5767 {
5768 if(unsigned(ri->idata) >= MAXITEMS)
5769 {
5770 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5771 ret = -10000;
5772 break;
5773 }
5774 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
5775 switch(index)
5776 {
5777 case 0:
5778 ret=(itemsbuf[ri->idata].misc1)*10000; break;
5779 case 1:
5780 ret=(itemsbuf[ri->idata].misc2)*10000; break;
5781 case 2:
5782 ret=(itemsbuf[ri->idata].misc3)*10000; break;
5783 case 3:
5784 ret=(itemsbuf[ri->idata].misc4)*10000; break;
5785 case 4:
5786 ret=(itemsbuf[ri->idata].misc5)*10000; break;
5787 case 5:
5788 ret=(itemsbuf[ri->idata].misc6)*10000; break;
5789 case 6:
5790 ret=(itemsbuf[ri->idata].misc7)*10000; break;
5791 case 7:
5792 ret=(itemsbuf[ri->idata].misc8)*10000; break;
5793 case 8:
5794 ret=(itemsbuf[ri->idata].misc9)*10000; break;
5795 case 9:
5796 ret=(itemsbuf[ri->idata].misc10)*10000; break;
5797 default:
5798 ret = -10000; break;
5799 }
5800
5801 break;
5802 }
5803 //Get the ->Sprite[] of an item.
5804 case IDATASPRITE:
5805 {
5806 if(unsigned(ri->idata) >= MAXITEMS)
5807 {
5808 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5809 ret = -10000;
5810 break;
5811 }
5812 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
5813 switch(index)
5814 {
5815 case 0:
5816 ret=(itemsbuf[ri->idata].wpn)*10000; break;
5817 case 1:
5818 ret=(itemsbuf[ri->idata].wpn2)*10000; break;
5819 case 2:
5820 ret=(itemsbuf[ri->idata].wpn3)*10000; break;
5821 case 3:
5822 ret=(itemsbuf[ri->idata].wpn4)*10000; break;
5823 case 4:
5824 ret=(itemsbuf[ri->idata].wpn5)*10000; break;
5825 case 5:
5826 ret=(itemsbuf[ri->idata].wpn6)*10000; break;
5827 case 6:
5828 ret=(itemsbuf[ri->idata].wpn7)*10000; break;
5829 case 7:
5830 ret=(itemsbuf[ri->idata].wpn8)*10000; break;
5831 case 8:
5832 ret=(itemsbuf[ri->idata].wpn9)*10000; break;
5833 case 9:
5834 ret=(itemsbuf[ri->idata].wpn10)*10000; break;
5835 default:
5836 ret = -10000; break;
5837 }
5838
5839 break;
5840 }
5841 //Hero TIle modifier
5842 case IDATALTM:
5843 if(unsigned(ri->idata) >= MAXITEMS)
5844 {
5845 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5846 ret = 0;
5847 break;
5848 }
5849 ret=(itemsbuf[ri->idata].ltm)*10000;
5850 break;
5851 //Pickup script
5852 case IDATAPSCRIPT:
5853 if(unsigned(ri->idata) >= MAXITEMS)
5854 {
5855 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5856 ret = -10000;
5857 break;
5858 }
5859 ret=(itemsbuf[ri->idata].collect_script)*10000;
5860 break;
5861 //Pickup string
5862 case IDATAPSTRING:
5863 if(unsigned(ri->idata) >= MAXITEMS)
5864 {
5865 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5866 ret = -10000;
5867 break;
5868 }
5869 ret=(itemsbuf[ri->idata].pstring)*10000;
5870 break;
5871 case IDATAPFLAGS:
5872 if(unsigned(ri->idata) >= MAXITEMS)
5873 {
5874 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5875 ret = 0;
5876 break;
5877 }
5878 ret=(itemsbuf[ri->idata].pickup_string_flags)*10000;
5879 break;
5880 //Magic cost
5881 case IDATAMAGCOST:
5882 if(unsigned(ri->idata) >= MAXITEMS)
5883 {
5884 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5885 ret = -10000;
5886 break;
5887 }
5888 ret=(itemsbuf[ri->idata].cost_amount[0])*10000;
5889 break;
5890 case IDATACOST2:
5891 if(unsigned(ri->idata) >= MAXITEMS)
5892 {
5893 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5894 ret = -10000;
5895 break;
5896 }
5897 ret=(itemsbuf[ri->idata].cost_amount[1])*10000;
5898 break;
5899 //cost counter ref
5900 case IDATACOSTCOUNTER:
5901 if(unsigned(ri->idata) >= MAXITEMS)
5902 {
5903 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5904 ret = -10000;
5905 break;
5906 }
5907 ret=(itemsbuf[ri->idata].cost_counter[0])*10000;
5908 break;
5909 case IDATACOSTCOUNTER2:
5910 if(unsigned(ri->idata) >= MAXITEMS)
5911 {
5912 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5913 ret = -10000;
5914 break;
5915 }
5916 ret=(itemsbuf[ri->idata].cost_counter[1])*10000;
5917 break;
5918 //Min Hearts to Pick Up
5919 case IDATAMINHEARTS:
5920 if(unsigned(ri->idata) >= MAXITEMS)
5921 {
5922 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5923 ret = -10000;
5924 break;
5925 }
5926 ret=(itemsbuf[ri->idata].pickup_hearts)*10000;
5927 break;
5928 //Tile used by the item
5929 case IDATATILE:
5930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50207 times.
50207 if(unsigned(ri->idata) >= MAXITEMS)
5931 {
5932 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5933 ret = -10000;
5934 break;
5935 }
5936 50207 ret=(itemsbuf[ri->idata].tile)*10000;
5937 50207 break;
5938 //itemdata->Flash
5939 case IDATAMISC:
5940 if(unsigned(ri->idata) >= MAXITEMS)
5941 {
5942 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5943 ret = -10000;
5944 break;
5945 }
5946 ret=(itemsbuf[ri->idata].misc_flags)*10000;
5947 break;
5948 //->CSet
5949 case IDATACSET:
5950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50207 times.
50207 if(unsigned(ri->idata) >= MAXITEMS)
5951 {
5952 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5953 ret = -10000;
5954 break;
5955 }
5956 50207 ret=(itemsbuf[ri->idata].csets)*10000;
5957 50207 break;
5958 //->A.Frames
5959 case IDATAFRAMES:
5960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61651 times.
61651 if(unsigned(ri->idata) >= MAXITEMS)
5961 {
5962 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5963 ret = -10000;
5964 break;
5965 }
5966 61651 ret=(itemsbuf[ri->idata].frames)*10000;
5967 61651 break;
5968 /*
5969 case IDATAFRAME:
5970 ret=(itemsbuf[ri->idata].frame)*10000;
5971 break;
5972 */
5973 //->A.Speed
5974 case IDATAASPEED:
5975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134799 times.
134799 if(unsigned(ri->idata) >= MAXITEMS)
5976 {
5977 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5978 ret = -10000;
5979 break;
5980 }
5981 134799 ret=(itemsbuf[ri->idata].speed)*10000;
5982 134799 break;
5983 //->Delay
5984 case IDATADELAY:
5985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73148 times.
73148 if(unsigned(ri->idata) >= MAXITEMS)
5986 {
5987 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5988 ret = -10000;
5989 break;
5990 }
5991 73148 ret=(itemsbuf[ri->idata].delay)*10000;
5992 73148 break;
5993 // teo of this item upgrades
5994 case IDATACOMBINE:
5995 ret = item_flag(ITEM_COMBINE);
5996 break;
5997 //Use item, and get the lower level one
5998 case IDATADOWNGRADE:
5999 ret = item_flag(ITEM_DOWNGRADE);
6000 break;
6001 //Only validate the cost, don't charge it
6002 case IDATAVALIDATE:
6003 ret = item_flag(ITEM_VALIDATEONLY);
6004 break;
6005 case IDATAVALIDATE2:
6006 ret = item_flag(ITEM_VALIDATEONLY2);
6007 break;
6008 //->Flags[5]
6009 case IDATAFLAGS:
6010 {
6011 if(unsigned(ri->idata) >= MAXITEMS)
6012 {
6013 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
6014 ret = 0;
6015 break;
6016 }
6017 int32_t index = ri->d[rINDEX]/10000;
6018 switch(index)
6019 {
6020 case 0:
6021 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG1)?10000:0; break;
6022 case 1:
6023 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG2)?10000:0; break;
6024 case 2:
6025 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG3)?10000:0; break;
6026 case 3:
6027 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG4)?10000:0; break;
6028 case 4:
6029 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG5)?10000:0; break;
6030 case 5:
6031 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG6)?10000:0; break;
6032 case 6:
6033 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG7)?10000:0; break;
6034 case 7:
6035 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG8)?10000:0; break;
6036 case 8:
6037 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG9)?10000:0; break;
6038 case 9:
6039 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG10)?10000:0; break;
6040 case 10:
6041 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG11)?10000:0; break;
6042 case 11:
6043 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG12)?10000:0; break;
6044 case 12:
6045 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG13)?10000:0; break;
6046 case 13:
6047 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG14)?10000:0; break;
6048 case 14:
6049 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG15)?10000:0; break;
6050 case 15:
6051 ret=(itemsbuf[ri->idata].flags & ITEM_PASSIVESCRIPT)?10000:0; break;
6052
6053
6054 default:
6055 Z_scripterrlog("Invalid itemdata->Flags[] index: %d\n", index);
6056 ret = 0;
6057 break;
6058 }
6059 break;
6060 }
6061
6062 //->Keep Old
6063 case IDATAKEEPOLD:
6064 ret = item_flag(ITEM_KEEPOLD);
6065 break;
6066 //Use rupees instead of magic
6067 case IDATARUPEECOST:
6068 ret = item_flag(ITEM_RUPEE_MAGIC);
6069 break;
6070 //Can be eaten
6071 case IDATAEDIBLE:
6072 ret = item_flag(ITEM_EDIBLE);
6073 break;
6074 //currently unused
6075 case IDATAFLAGUNUSED:
6076 ret = item_flag(ITEM_UNUSED);
6077 break;
6078 //Gain lower level items when collected
6079 case IDATAGAINLOWER:
6080 ret = item_flag(ITEM_GAINOLD);
6081 break;
6082 //Unchanged from master
6083 case IDATAINITDD:
6084 {
6085 int32_t a = ri->d[rINDEX] / 10000;
6086 if(unsigned(ri->idata) >= MAXITEMS)
6087 {
6088 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
6089 ret = -10000;
6090 break;
6091 }
6092
6093 if(BC::checkBounds(a, 0, 7, "itemdata->InitD") != SH::_NoError)
6094 ret = -10000;
6095 else
6096 ret = itemsbuf[ri->idata].initiald[a];
6097 }
6098 break;
6099
6100 ///----------------------------------------------------------------------------------------------------//
6101 //NPC Variables
6102
6103 //Reduces accessing integer members to one line
6104 #define GET_NPC_VAR_INT(member, str) \
6105 { \
6106 if(GuyH::loadNPC(ri->guyref, str) != SH::_NoError) \
6107 ret = -10000; \
6108 else \
6109 ret = GuyH::getNPC()->member * 10000; \
6110 }
6111
6112 case NPCDIR:
6113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77691 times.
77691 if(GuyH::loadNPC(ri->guyref, "npc->Dir") != SH::_NoError)
6114 ret = -10000;
6115 else
6116
1/2
✓ Branch 0 taken 77691 times.
✗ Branch 1 not taken.
77691 ret = zc_max(GuyH::getNPC()->dir * 10000, 0);
6117
6118 77691 break;
6119
6120 case NPCHITDIR:
6121 if(GuyH::loadNPC(ri->guyref, "npc->HitDir") != SH::_NoError)
6122 ret = -10000;
6123 else
6124 ret = (GuyH::getNPC()->hitdir * 10000);
6125
6126 break;
6127
6128 case NPCSLIDECLK:
6129 if(GuyH::loadNPC(ri->guyref, "npc->SlideClock") != SH::_NoError)
6130 ret = -10000;
6131 else
6132 ret = (GuyH::getNPC()->sclk * 10000);
6133
6134 break;
6135
6136 case NPCHALTCLK:
6137 if(GuyH::loadNPC(ri->guyref, "npc->Halt") != SH::_NoError)
6138 ret = -10000;
6139 else
6140 ret = (GuyH::getNPC()->clk2 * 10000);
6141
6142 break;
6143
6144 case NPCFRAME:
6145 if(GuyH::loadNPC(ri->guyref, "npc->Frame") != SH::_NoError)
6146 ret = -10000;
6147 else
6148 ret = (GuyH::getNPC()->clk * 10000);
6149
6150 break;
6151
6152 case NPCMOVESTATUS:
6153 if(GuyH::loadNPC(ri->guyref, "npc->MoveStatus") != SH::_NoError)
6154 ret = -10000;
6155 else
6156 ret = (GuyH::getNPC()->movestatus * 10000);
6157
6158 break;
6159
6160 case NPCFADING:
6161 if(GuyH::loadNPC(ri->guyref, "npc->Fading") != SH::_NoError)
6162 ret = -10000;
6163 else
6164 ret = (GuyH::getNPC()->fading * 10000);
6165
6166 break;
6167
6168 case NPCRATE:
6169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 426414 times.
426414 GET_NPC_VAR_INT(rate, "npc->Rate") break;
6170
6171 case NPCHOMING:
6172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436097 times.
436097 GET_NPC_VAR_INT(homing, "npc->Homing") break;
6173
6174 case NPCFRAMERATE:
6175 GET_NPC_VAR_INT(frate, "npc->ASpeed") break;
6176
6177 case NPCHALTRATE:
6178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410674 times.
410674 GET_NPC_VAR_INT(hrate, "npc->HaltRate") break;
6179
6180 case NPCRANDOM:
6181 GET_NPC_VAR_INT(rate, "npc->Random") break;
6182
6183 case NPCDRAWTYPE:
6184 GET_NPC_VAR_INT(drawstyle, "npc->DrawStyle") break;
6185
6186 case NPCHP:
6187
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5126982 times.
5126984 GET_NPC_VAR_INT(hp, "npc->HP") break;
6188
6189 case NPCORIGINALHP:
6190 GET_NPC_VAR_INT(starting_hp, "npc->OriginalHP") break;
6191
6192 case NPCCOLLDET:
6193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165740 times.
165740 GET_NPC_VAR_INT(scriptcoldet, "npc->ColDetection") break;
6194
6195 case NPCENGINEANIMATE:
6196 GET_NPC_VAR_INT(do_animation, "npc->Animation") break;
6197
6198 case NPCSTUN:
6199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1130026 times.
1130026 GET_NPC_VAR_INT(stunclk, "npc->Stun") break;
6200
6201 case NPCHUNGER:
6202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472577 times.
472577 GET_NPC_VAR_INT(grumble, "npc->Hunger") break;
6203
6204 case NPCWEAPSPRITE:
6205 GET_NPC_VAR_INT(wpnsprite, "npc->WeaponSprite") break;
6206
6207 case NPCTYPE:
6208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532410 times.
532410 GET_NPC_VAR_INT(family, "npc->Type") break;
6209
6210 case NPCDP:
6211
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3165 times.
3169 GET_NPC_VAR_INT(dp, "npc->Damage") break;
6212
6213 case NPCWDP:
6214
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 12956 times.
13200 GET_NPC_VAR_INT(wdp, "npc->WeaponDamage") break;
6215
6216 case NPCOTILE:
6217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5408 times.
5408 GET_NPC_VAR_INT(o_tile, "npc->OriginalTile") break;
6218
6219 case NPCTILE:
6220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39139 times.
39139 GET_NPC_VAR_INT(tile, "npc->Tile") break;
6221
6222 case NPCSCRIPTTILE:
6223 GET_NPC_VAR_INT(scripttile, "npc->ScriptTile") break;
6224
6225 case NPCSCRIPTFLIP:
6226 GET_NPC_VAR_INT(scriptflip, "npc->ScriptFlip") break;
6227
6228 case NPCWEAPON:
6229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
404 GET_NPC_VAR_INT(wpn, "npc->Weapon") break;
6230
6231 case NPCITEMSET:
6232 GET_NPC_VAR_INT(item_set, "npc->ItemSet") break;
6233
6234 case NPCCSET:
6235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17988 times.
17988 GET_NPC_VAR_INT(cs, "npc->CSet") break;
6236
6237 case NPCBOSSPAL:
6238 GET_NPC_VAR_INT(bosspal, "npc->BossPal") break;
6239
6240 case NPCBGSFX:
6241 GET_NPC_VAR_INT(bgsfx, "npc->SFX") break;
6242
6243 case NPCEXTEND:
6244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6086 times.
6086 GET_NPC_VAR_INT(extend, "npc->Extend") break;
6245
6246 case NPCHXOFS:
6247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383015 times.
383015 GET_NPC_VAR_INT(hxofs, "npc->HitXOffset") break;
6248
6249 case NPCHYOFS:
6250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383015 times.
383015 GET_NPC_VAR_INT(hyofs, "npc->HitYOffset") break;
6251
6252 case NPCHXSZ:
6253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 427914 times.
427914 GET_NPC_VAR_INT(hit_width, "npc->HitWidth") break;
6254
6255 case NPCHYSZ:
6256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 427914 times.
427914 GET_NPC_VAR_INT(hit_height, "npc->HitHeight") break;
6257
6258 case NPCHZSZ:
6259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226198 times.
226198 GET_NPC_VAR_INT(hzsz, "npc->HitZHeight") break;
6260
6261 case NPCROTATION:
6262 if ( get_qr(qr_OLDSPRITEDRAWS) )
6263 {
6264 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
6265 "npc->Rotation");
6266 ret = -1; break;
6267 }
6268 GET_NPC_VAR_INT(rotation, "npc->Rotation") break;
6269
6270 case NPCTXSZ:
6271
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1504871 times.
1505295 GET_NPC_VAR_INT(txsz, "npc->TileWidth") break;
6272
6273 case NPCTYSZ:
6274
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1486996 times.
1487420 GET_NPC_VAR_INT(tysz, "npc->TileHeight") break;
6275
6276 //And zfix
6277 #define GET_NPC_VAR_FIX(member, str) \
6278 { \
6279 if(GuyH::loadNPC(ri->guyref, str) != SH::_NoError) \
6280 { \
6281 ret = -10000; \
6282 break; \
6283 } \
6284 else \
6285 ret = (int32_t(GuyH::getNPC()->member) * 10000); \
6286 }
6287
6288 case NPCX:
6289 //GET_NPC_VAR_FIX(x, "npc->X") break;
6290 {
6291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1058433 times.
1058433 if(GuyH::loadNPC(ri->guyref, "X") != SH::_NoError)
6292 {
6293 ret = -10000;
6294 }
6295 else
6296 {
6297
2/2
✓ Branch 0 taken 11123 times.
✓ Branch 1 taken 1047310 times.
1058433 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6298 {
6299 11123 ret = ((GuyH::getNPC()->x).getZLong());
6300 11123 }
6301 else
6302 {
6303 1047310 ret = (int32_t(GuyH::getNPC()->x) * 10000);
6304 }
6305 }
6306 1058433 break;
6307 }
6308
6309 case SPRITEMAXNPC:
6310 {
6311 //No bounds check, as this is a universal function and works from NULL pointers!
6312 ret = guys.getMax() * 10000;
6313 break;
6314 }
6315
6316 case NPCSUBMERGED:
6317 {
6318 if(GuyH::loadNPC(ri->guyref, "Submerged()") != SH::_NoError)
6319 {
6320 ret = -10000;
6321 }
6322 else
6323 {
6324 ret = ((GuyH::getNPC()->isSubmerged()) ? 10000 : 0);
6325
6326 }
6327 break;
6328 }
6329
6330
6331 case NPCY:
6332 //GET_NPC_VAR_FIX(y, "npc->Y") break;
6333 {
6334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1035974 times.
1035974 if(GuyH::loadNPC(ri->guyref, "Y") != SH::_NoError)
6335 {
6336 ret = -10000;
6337 }
6338 else
6339 {
6340
2/2
✓ Branch 0 taken 11122 times.
✓ Branch 1 taken 1024852 times.
1035974 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6341 {
6342 11122 ret = ((GuyH::getNPC()->y).getZLong());
6343 11122 }
6344 else
6345 {
6346 1024852 ret = (int32_t(GuyH::getNPC()->y) * 10000);
6347 }
6348 }
6349 1035974 break;
6350 }
6351
6352
6353 case NPCZ:
6354 //GET_NPC_VAR_FIX(z, "npc->Z") break;
6355 {
6356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 603415 times.
603415 if(GuyH::loadNPC(ri->guyref, "Z") != SH::_NoError)
6357 {
6358 ret = -10000;
6359 }
6360 else
6361 {
6362
2/2
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 602857 times.
603415 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6363 {
6364 558 ret = ((GuyH::getNPC()->z).getZLong());
6365 558 }
6366 else
6367 {
6368 602857 ret = (int32_t(GuyH::getNPC()->z) * 10000);
6369 }
6370 }
6371 603415 break;
6372 }
6373
6374 case NPCXOFS:
6375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2064045 times.
2064045 GET_NPC_VAR_FIX(xofs, "npc->DrawXOffset") break;
6376
6377 case NPCYOFS:
6378
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2065021 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2065021 times.
2065021 GET_NPC_VAR_FIX(yofs, "npc->DrawYOffset") ret-=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)*10000;
6379 2065021 break;
6380 case NPCSHADOWXOFS:
6381 GET_NPC_VAR_FIX(shadowxofs, "npc->ShadowXOffset") break;
6382
6383 case NPCSHADOWYOFS:
6384 GET_NPC_VAR_FIX(shadowyofs, "npc->ShadowYOffset") break;
6385
6386 case NPCTOTALDYOFFS:
6387 {
6388 if(GuyH::loadNPC(ri->guyref, "npc->TotalDYOffset") != SH::_NoError)
6389 {
6390 ret = -10000;
6391 }
6392 else
6393 {
6394 ret = ((int32_t(GuyH::getNPC()->yofs - (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))
6395 + ((GuyH::getNPC()->switch_hooked && Hero.switchhookstyle == swRISE)
6396 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0)) * 10000);
6397 }
6398 break;
6399 }
6400
6401 case NPCZOFS:
6402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2064017 times.
2064017 GET_NPC_VAR_FIX(zofs, "npc->DrawZOffset") break;
6403
6404 //These variables are all different to the templates (casting for jump and step is slightly non-standard)
6405 case NPCJUMP:
6406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75623 times.
75623 if(GuyH::loadNPC(ri->guyref, "npc->Jump") != SH::_NoError)
6407 ret = -10000;
6408 else
6409 {
6410 75623 ret = GuyH::getNPC()->fall.getZLong() / -100;
6411
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 75344 times.
75623 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6412 }
6413
6414 75623 break;
6415
6416 case NPCFAKEJUMP:
6417 if(GuyH::loadNPC(ri->guyref, "npc->FakeJump") != SH::_NoError)
6418 ret = -10000;
6419 else
6420 {
6421 ret = GuyH::getNPC()->fakefall.getZLong() / -100;
6422 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6423 }
6424
6425 break;
6426
6427
6428 case NPCSCALE:
6429 if ( get_qr(qr_OLDSPRITEDRAWS) )
6430 {
6431 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
6432 "npc->Scale");
6433 ret = -1; break;
6434 }
6435 if(GuyH::loadNPC(ri->guyref, "npc->Scale") != SH::_NoError)
6436 ret = -10000;
6437 else
6438 ret = (int32_t(GuyH::getNPC()->scale) * 100.0);
6439
6440 break;
6441
6442 case NPCIMMORTAL:
6443 if(GuyH::loadNPC(ri->guyref, "npc->Immortal") != SH::_NoError)
6444 ret = -10000;
6445 else
6446 ret = GuyH::getNPC()->immortal ? 10000 : 0;
6447 break;
6448
6449 case NPCNOSLIDE:
6450 if(GuyH::loadNPC(ri->guyref, "npc->NoSlide") != SH::_NoError)
6451 ret = -10000;
6452 else
6453 ret = (GuyH::getNPC()->knockbackflags & FLAG_NOSLIDE) ? 10000 : 0;
6454 break;
6455
6456 case NPCNOSCRIPTKB:
6457 if(GuyH::loadNPC(ri->guyref, "npc->NoScriptKnockback") != SH::_NoError)
6458 ret = -10000;
6459 else
6460 ret = (GuyH::getNPC()->knockbackflags & FLAG_NOSCRIPTKNOCKBACK) ? 10000 : 0;
6461 break;
6462
6463 case NPCKNOCKBACKSPEED:
6464 if(GuyH::loadNPC(ri->guyref, "npc->SlideSpeed") != SH::_NoError)
6465 ret = -10000;
6466 else
6467 ret = GuyH::getNPC()->knockbackSpeed * 10000;
6468 break;
6469
6470 case NPCSTEP:
6471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527244 times.
527244 if(GuyH::loadNPC(ri->guyref, "npc->Step") != SH::_NoError)
6472 ret = -10000;
6473 else
6474 {
6475
3/4
✓ Branch 0 taken 487718 times.
✓ Branch 1 taken 39526 times.
✓ Branch 2 taken 487718 times.
✗ Branch 3 not taken.
527244 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
6476 {
6477 527244 ret = ( ( (GuyH::getNPC()->step).getZLong() ) * 100 );
6478 527244 }
6479 //old, buggy code replication, round two: Go! -Z
6480 //else ret = ( ( (GuyH::getNPC()->step) * 100.0 ).getZLong() );
6481 else
6482 {
6483 double s2 = ( (GuyH::getNPC()->step).getZLong() );
6484 ret = int32_t(s2*100);
6485 //ret = int32_t( ( (GuyH::getNPC()->step) * 100.0 )) * 10000;
6486 }
6487 //else ret = int32_t(GuyH::getNPC()->step * fix(100.0)) * 10000;
6488
6489 //else
6490 //{
6491 //old, buggy code replication, round THREE: Go! -Z
6492 // double tmp = ( (GuyH::getNPC()->step) ) * 1000000.0;
6493 // ret = (int32_t)tmp;
6494 //}
6495 }
6496
6497 527244 break;
6498
6499 case NPCGRAVITY:
6500 if(GuyH::loadNPC(ri->guyref, "npc->Gravity") != SH::_NoError)
6501 ret = -10000;
6502 else
6503 ret = ((GuyH::getNPC()->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0);
6504
6505 break;
6506
6507
6508 case NPCID:
6509
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 22518976 times.
22519029 if(GuyH::loadNPC(ri->guyref, "npc->ID") != SH::_NoError)
6510 53 ret = -10000;
6511 else
6512 22518976 ret = (GuyH::getNPC()->id & 0xFFF) * 10000;
6513
6514 22519029 break;
6515
6516 case NPCISCORE:
6517 if(GuyH::loadNPC(ri->guyref, "npc->isCore") != SH::_NoError)
6518 ret = -10000;
6519 else
6520 ret = ((GuyH::getNPC()->isCore) ? 10000 : 0);
6521
6522 break;
6523
6524 case NPCSCRIPTUID:
6525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 598 times.
598 if(GuyH::loadNPC(ri->guyref, "npc->ScriptUID") != SH::_NoError)
6526 ret = -10000;
6527 else
6528 598 ret = ((GuyH::getNPC()->getScriptUID())); //literal, not *10000
6529
6530 598 break;
6531
6532 case NPCPARENTUID:
6533 if(GuyH::loadNPC(ri->guyref, "npc->ParentUID") != SH::_NoError)
6534 ret = -10000;
6535 else
6536 ret = ((GuyH::getNPC()->parent_script_UID)); //literal, not *10000
6537
6538 break;
6539
6540 //case EWPNPARENTUID:
6541 //if(0!=(s=checkEWpn(ri->ewpn, "ScriptUID")))
6542 // ret=(((weapon*)(s))->parent_script_UID); //literal, not *10000
6543
6544
6545 case NPCMFLAGS:
6546
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 3672506 times.
3672930 if(GuyH::loadNPC(ri->guyref, "npc->MiscFlags") != SH::_NoError)
6547 424 ret = -10000;
6548 else
6549 3672506 ret = GuyH::getMFlags() * 10000;
6550
6551 3672930 break;
6552
6553 //Indexed (two checks)
6554 case NPCDEFENSED:
6555 {
6556 167669 int32_t a = ri->d[rINDEX] / 10000;
6557
6558
2/4
✓ Branch 0 taken 167669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167669 times.
167669 if(GuyH::loadNPC(ri->guyref, "npc->Defense[]") != SH::_NoError ||
6559 167669 BC::checkBounds(a, 0, (edefLAST255), "npc->Defense[]") != SH::_NoError)
6560 ret = -10000;
6561 else
6562 167669 ret = GuyH::getNPC()->defense[a] * 10000;
6563 }
6564 167669 break;
6565
6566 case NPCHITBY:
6567 {
6568 268246 int32_t indx = ri->d[rINDEX] / 10000;
6569
6570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 268246 times.
268246 if(GuyH::loadNPC(ri->guyref, "npc->HitBy[]") != SH::_NoError )
6571 {
6572 ret = -10000; break;
6573 }
6574 else
6575 {
6576
2/3
✓ Branch 0 taken 134123 times.
✓ Branch 1 taken 134123 times.
✗ Branch 2 not taken.
268246 switch(indx)
6577 {
6578 //screen indixes
6579 case 0:
6580 case 1:
6581 case 2:
6582 case 3:
6583 case 8:
6584 case 9:
6585 case 10:
6586 case 11:
6587 case 12:
6588 case 16:
6589 {
6590 134123 ret = GuyH::getNPC()->hitby[indx] * 10000; // * 10000; //do not multiply by 10000! UIDs are not *10000!
6591 134123 break;
6592 }
6593 //UIDs
6594 case 4:
6595 case 5:
6596 case 6:
6597 case 7:
6598 case 13:
6599 case 14:
6600 case 15:
6601 {
6602 134123 ret = GuyH::getNPC()->hitby[indx]; // * 10000; //do not multiply by 10000! UIDs are not *10000!
6603 134123 break;
6604 }
6605 default: { Z_scripterrlog("Invalid index used for npc->HitBy[%d]. /n", indx); ret = -10000; break; }
6606 }
6607 268246 break;
6608 }
6609 }
6610
6611 //2.fuure compat.
6612
6613 case NPCSCRDEFENSED:
6614 {
6615 int32_t a = ri->d[rINDEX] / 10000;
6616
6617 if(GuyH::loadNPC(ri->guyref, "npc->ScriptDefense") != SH::_NoError ||
6618 BC::checkBounds(a, 0, edefSCRIPTDEFS_MAX, "npc->ScriptDefense") != SH::_NoError)
6619 ret = -10000;
6620 else
6621 ret = GuyH::getNPC()->defense[a+edefSCRIPT01] * 10000;
6622 }
6623 break;
6624
6625
6626 case NPCMISCD:
6627 {
6628 11384507 int32_t a = ri->d[rINDEX] / 10000;
6629
6630
3/4
✓ Branch 0 taken 11384468 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11384468 times.
11384507 if(GuyH::loadNPC(ri->guyref, "npc->Misc") != SH::_NoError ||
6631 11384468 BC::checkMisc32(a, "npc->Misc") != SH::_NoError)
6632 39 ret = -10000;
6633 else
6634 11384468 ret = GuyH::getNPC()->miscellaneous[a];
6635 }
6636 11384507 break;
6637 case NPCINITD:
6638 {
6639 int32_t a = ri->d[rINDEX] / 10000;
6640
6641 if(GuyH::loadNPC(ri->guyref, "npc->InitD[]") != SH::_NoError )
6642 ret = -10000;
6643 else
6644 {
6645 //enemy *e = (enemy*)guys.spr(ri->guyref);
6646 ret = (int32_t)GuyH::getNPC()->initD[a];
6647 }
6648 }
6649 break;
6650
6651 case NPCSCRIPT:
6652 {
6653 if(GuyH::loadNPC(ri->guyref, "npc->Script") != SH::_NoError )
6654 ret = -10000;
6655 else
6656 {
6657 //enemy *e = (enemy*)guys.spr(ri->guyref);
6658 ret = (int32_t)GuyH::getNPC()->script * 10000;
6659 }
6660 }
6661 break;
6662
6663 case NPCDD: //Fized the size of this array. There are 15 total attribs, [0] to [14], not [0] to [9]. -Z
6664 {
6665 6431345 int32_t a = ri->d[rINDEX] / 10000;
6666
6667
2/4
✓ Branch 0 taken 6431345 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6431345 times.
6431345 if(GuyH::loadNPC(ri->guyref, "npc->Attributes") != SH::_NoError ||
6668 6431345 BC::checkBounds(a, 0, ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ? 31 : 15 ), "npc->Attributes") != SH::_NoError)
6669 ret = -10000;
6670 else
6671 6431345 ret = GuyH::getNPCDMisc(a) * 10000;
6672 }
6673 6431345 break;
6674
6675 case NPCINVINC:
6676 if(GuyH::loadNPC(ri->guyref, "npc->InvFrames") != SH::_NoError)
6677 ret = -10000;
6678 else
6679 ret = (int32_t)GuyH::getNPC()->hclk * 10000;
6680
6681 break;
6682
6683 case NPCHASITEM:
6684 if(GuyH::loadNPC(ri->guyref, "npc->HasItem") != SH::_NoError)
6685 ret = 0;
6686 else
6687 ret = GuyH::getNPC()->itemguy?10000:0;
6688
6689 break;
6690
6691 case NPCRINGLEAD:
6692 if(GuyH::loadNPC(ri->guyref, "npc->Ringleader") != SH::_NoError)
6693 ret = 0;
6694 else
6695 ret = GuyH::getNPC()->leader?10000:0;
6696
6697 break;
6698
6699 case NPCSUPERMAN:
6700 if(GuyH::loadNPC(ri->guyref, "npc->Invincible") != SH::_NoError)
6701 ret = -10000;
6702 else
6703 ret = (int32_t)GuyH::getNPC()->superman * 10000;
6704
6705 break;
6706
6707 case NPCSHIELD:
6708 {
6709 int32_t indx = ri->d[rINDEX];
6710 if(GuyH::loadNPC(ri->guyref, "npc->Shield[]") == SH::_NoError)
6711 {
6712 switch(indx)
6713 {
6714 case 0:
6715 {
6716 ret = ((GuyH::getNPC()->flags&inv_front) ? 10000 : 0);
6717 break;
6718 }
6719 case 1:
6720 {
6721 ret = ((GuyH::getNPC()->flags&inv_left) ? 10000 : 0);
6722 break;
6723 }
6724 case 2:
6725 {
6726 ret = ((GuyH::getNPC()->flags&inv_right) ? 10000 : 0);
6727 break;
6728 }
6729 case 3:
6730 {
6731 ret = ((GuyH::getNPC()->flags&inv_back) ? 10000 : 0);
6732 break;
6733 }
6734 case 4: //shield can be broken
6735 {
6736 ret = ((GuyH::getNPC()->flags&guy_bkshield) ? 10000 : 0);
6737 break;
6738 }
6739 default:
6740 {
6741 Z_scripterrlog("Invalid Array Index passed to npc->Shield[]: %d\n", indx);
6742 break;
6743 }
6744 }
6745 }
6746 else
6747 {
6748 ret = -10000;
6749 break;
6750 }
6751 }
6752 break;
6753
6754 case NPCFROZENTILE:
6755 GET_NPC_VAR_INT(frozentile, "npc->FrozenTile"); break;
6756
6757 case NPCFROZENCSET:
6758 GET_NPC_VAR_INT(frozencset, "npc->FrozenCSet"); break;
6759
6760 case NPCFROZEN:
6761 GET_NPC_VAR_INT(frozenclock, "npc->Frozen"); break;
6762
6763
6764 case NPCBEHAVIOUR:
6765 {
6766 if(GuyH::loadNPC(ri->guyref, "npc->Behaviour[]") != SH::_NoError)
6767 {
6768 ret = -10000;
6769 break;
6770 }
6771
6772 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
6773 switch(index)
6774 {
6775 case 0:
6776 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG1)?10000:0; break;
6777 case 1:
6778 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG2)?10000:0; break;
6779 case 2:
6780 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG3)?10000:0; break;
6781 case 3:
6782 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG4)?10000:0; break;
6783 case 4:
6784 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG5)?10000:0; break;
6785 case 5:
6786 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG6)?10000:0; break;
6787 case 6:
6788 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG7)?10000:0; break;
6789 case 7:
6790 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG8)?10000:0; break;
6791 case 8:
6792 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG9)?10000:0; break;
6793 case 9:
6794 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG10)?10000:0; break;
6795 case 10:
6796 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG11)?10000:0; break;
6797 case 11:
6798 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG12)?10000:0; break;
6799 case 12:
6800 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG13)?10000:0; break;
6801 case 13:
6802 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG14)?10000:0; break;
6803 case 14:
6804 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG15)?10000:0; break;
6805 case 15:
6806 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG16)?10000:0; break;
6807
6808 default:
6809 ret = 0; break;
6810 }
6811
6812 break;
6813 }
6814
6815 case NPCFALLCLK:
6816 if(GuyH::loadNPC(ri->guyref, "npc->Falling") == SH::_NoError)
6817 {
6818 ret = GuyH::getNPC()->fallclk * 10000;
6819 }
6820 break;
6821
6822 case NPCFALLCMB:
6823 if(GuyH::loadNPC(ri->guyref, "npc->FallCombo") == SH::_NoError)
6824 {
6825 ret = GuyH::getNPC()->fallCombo * 10000;
6826 }
6827 break;
6828
6829 case NPCDROWNCLK:
6830 if(GuyH::loadNPC(ri->guyref, "npc->Drowning") == SH::_NoError)
6831 {
6832 ret = GuyH::getNPC()->drownclk * 10000;
6833 }
6834 break;
6835
6836 case NPCDROWNCMB:
6837 if(GuyH::loadNPC(ri->guyref, "npc->DrownCombo") == SH::_NoError)
6838 {
6839 ret = GuyH::getNPC()->drownCombo * 10000;
6840 }
6841 break;
6842
6843 case NPCFAKEZ:
6844 {
6845 if(GuyH::loadNPC(ri->guyref, "FakeZ") != SH::_NoError)
6846 {
6847 ret = -10000;
6848 }
6849 else
6850 {
6851 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6852 {
6853 ret = ((GuyH::getNPC()->fakez).getZLong());
6854 }
6855 else
6856 {
6857 ret = (int32_t(GuyH::getNPC()->fakez) * 10000);
6858 }
6859 }
6860 break;
6861 }
6862
6863 case NPCMOVEFLAGS:
6864 {
6865 if(GuyH::loadNPC(ri->guyref, "npc->MoveFlags[]") == SH::_NoError)
6866 {
6867 int32_t indx = ri->d[rINDEX]/10000;
6868 if(BC::checkBounds(indx, 0, 15, "npc->MoveFlags[]") != SH::_NoError)
6869 ret = 0; //false
6870 else
6871 {
6872 //All bits, in order, of a single byte; just use bitwise
6873 ret = (GuyH::getNPC()->moveflags & (1<<indx)) ? 10000 : 0;
6874 }
6875 }
6876 break;
6877 }
6878
6879 case NPCGLOWRAD:
6880 if(GuyH::loadNPC(ri->guyref, "npc->LightRadius") == SH::_NoError)
6881 {
6882 ret = GuyH::getNPC()->glowRad * 10000;
6883 }
6884 break;
6885
6886 case NPCGLOWSHP:
6887 if(GuyH::loadNPC(ri->guyref, "npc->LightShape") == SH::_NoError)
6888 {
6889 ret = GuyH::getNPC()->glowShape * 10000;
6890 }
6891 break;
6892
6893 case NPCSHADOWSPR:
6894 if(GuyH::loadNPC(ri->guyref, "npc->ShadowSprite") == SH::_NoError)
6895 {
6896 ret = GuyH::getNPC()->spr_shadow * 10000;
6897 }
6898 break;
6899 case NPCSPAWNSPR:
6900 if(GuyH::loadNPC(ri->guyref, "npc->SpawnSprite") == SH::_NoError)
6901 {
6902 ret = GuyH::getNPC()->spr_spawn * 10000;
6903 }
6904 break;
6905 case NPCDEATHSPR:
6906 if(GuyH::loadNPC(ri->guyref, "npc->DeathSprite") == SH::_NoError)
6907 {
6908 ret = GuyH::getNPC()->spr_death * 10000;
6909 }
6910 break;
6911 case NPCSWHOOKED:
6912 if(GuyH::loadNPC(ri->guyref, "npc->SwitchHooked") == SH::_NoError)
6913 {
6914 ret = GuyH::getNPC()->switch_hooked ? 10000 : 0;
6915 }
6916 break;
6917 case NPCCANFLICKER:
6918 if(GuyH::loadNPC(ri->guyref, "npc->InvFlicker") == SH::_NoError)
6919 {
6920 ret = GuyH::getNPC()->getCanFlicker() ? 10000 : 0;
6921 }
6922 break;
6923
6924
6925
6926 ///----------------------------------------------------------------------------------------------------//
6927 //LWeapon Variables
6928 case LWPNSPECIAL:
6929 if(0!=(s=checkLWpn(ri->lwpn,"Special")))
6930 ret=((int32_t)((weapon*)(s))->specialinfo)*10000;
6931
6932
6933 break;
6934
6935 case LWPNSCALE:
6936 if ( get_qr(qr_OLDSPRITEDRAWS) )
6937 {
6938 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
6939 "lweapon->Scale");
6940 ret = -1; break;
6941 }
6942 if(0!=(s=checkLWpn(ri->lwpn,"Scale")))
6943 ret=((int32_t)((weapon*)(s))->scale)*100.0;
6944
6945 break;
6946
6947 case LWPNX:
6948
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 700149 times.
713905 if(0!=(s=checkLWpn(ri->lwpn,"X")))
6949 {
6950
2/2
✓ Branch 0 taken 153140 times.
✓ Branch 1 taken 547009 times.
700149 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6951 {
6952 153140 ret=(((weapon*)(s))->x).getZLong();
6953 153140 }
6954 else
6955 547009 ret=((int32_t)((weapon*)(s))->x)*10000;
6956 700149 }
6957
6958 713905 break;
6959
6960 case SPRITEMAXLWPN:
6961 {
6962 //No bounds check, as this is a universal function and works from NULL pointers!
6963 ret = Lwpns.getMax() * 10000;
6964 break;
6965 }
6966
6967 case LWPNY:
6968
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 695675 times.
709431 if(0!=(s=checkLWpn(ri->lwpn,"Y")))
6969 {
6970
2/2
✓ Branch 0 taken 153140 times.
✓ Branch 1 taken 542535 times.
695675 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6971 {
6972 153140 ret=(((weapon*)(s))->y).getZLong();
6973 153140 }
6974 else
6975 542535 ret=((int32_t)((weapon*)(s))->y)*10000;
6976 695675 }
6977 709431 break;
6978
6979 case LWPNZ:
6980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55748 times.
55748 if(0!=(s=checkLWpn(ri->lwpn,"Z")))
6981 {
6982
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 55746 times.
55748 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6983 {
6984 2 ret=(((weapon*)(s))->z).getZLong();
6985 2 }
6986 else
6987 55746 ret=((int32_t)((weapon*)(s))->z)*10000;
6988 55748 }
6989
6990 55748 break;
6991
6992 case LWPNJUMP:
6993 if(0!=(s=checkLWpn(ri->lwpn,"Jump")))
6994 {
6995 ret = ((weapon*)(s))->fall.getZLong() / -100;
6996 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6997 }
6998
6999 break;
7000
7001 case LWPNFAKEJUMP:
7002 if(0!=(s=checkLWpn(ri->lwpn,"FakeJump")))
7003 {
7004 ret = ((weapon*)(s))->fakefall.getZLong() / -100;
7005 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
7006 }
7007
7008 break;
7009
7010 case LWPNDIR:
7011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67667 times.
67667 if(0!=(s=checkLWpn(ri->lwpn,"Dir")))
7012 67667 ret=((weapon*)(s))->dir*10000;
7013
7014 67667 break;
7015
7016 case LWPNGRAVITY:
7017 if(0!=(s=checkLWpn(ri->lwpn,"Gravity")))
7018 ret= (((weapon*)(s))->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0;
7019
7020 break;
7021
7022 case LWPNSTEP:
7023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
1329 if(0!=(s=checkLWpn(ri->lwpn,"Step")))
7024 {
7025
3/4
✓ Branch 0 taken 1134 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 1134 times.
✗ Branch 3 not taken.
1329 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
7026 {
7027 1329 ret=((weapon*)s)->step.getZLong() * 100;
7028 1329 }
7029 //old, buggy code replication, round two: Go! -Z
7030 //else ret = ( ( ( ((weapon*)s)->step ) * 100.0 ).getZLong() );
7031
7032 //else
7033 //{
7034 //old, buggy code replication, round THREE: Go! -Z
7035 // double tmp = ( ((weapon*)s)->step.getFloat() ) * 1000000.0;
7036 // ret = (int32_t)tmp;
7037 //}
7038
7039 //old, buggy code replication, round FOUR: Go! -Z
7040 else ret = (int32_t)((float)((weapon*)s)->step * 1000000.0);
7041 1329 }
7042 1329 break;
7043
7044 case LWPNANGLE:
7045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(0!=(s=checkLWpn(ri->lwpn,"Angle")))
7046 2 ret=(int32_t)(((weapon*)(s))->angle*10000);
7047
7048 2 break;
7049
7050 case LWPNDEGANGLE:
7051 if(0!=(s=checkLWpn(ri->lwpn,"DegAngle")))
7052 {
7053 ret=(int32_t)(((weapon*)(s))->angle*(180.0 / PI)*10000);
7054 }
7055
7056 break;
7057
7058 case LWPNVX:
7059 if(0!=(s=checkLWpn(ri->lwpn,"Vx")))
7060 {
7061 if (((weapon*)(s))->angular)
7062 ret = int32_t(zc::math::Cos(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
7063 else
7064 {
7065 switch(NORMAL_DIR(((weapon*)(s))->dir))
7066 {
7067 case l_up:
7068 case l_down:
7069 case left:
7070 ret = int32_t(-10000.0*((weapon*)s)->step);
7071 break;
7072
7073 case r_down:
7074 case r_up:
7075 case right:
7076 ret = int32_t(10000.0*((weapon*)s)->step);
7077 break;
7078
7079 default:
7080 ret = 0;
7081 break;
7082 }
7083 }
7084 }
7085
7086 break;
7087
7088 case LWPNVY:
7089 if(0!=(s=checkLWpn(ri->lwpn,"Vy")))
7090 {
7091 if (((weapon*)(s))->angular)
7092 ret = int32_t(zc::math::Sin(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
7093 else
7094 {
7095 switch(NORMAL_DIR(((weapon*)(s))->dir))
7096 {
7097 case l_up:
7098 case r_up:
7099 case up:
7100 ret = int32_t(-10000.0*((weapon*)s)->step);
7101 break;
7102 case l_down:
7103 case r_down:
7104 case down:
7105 ret = int32_t(10000.0*((weapon*)s)->step);
7106 break;
7107
7108 default:
7109 ret = 0;
7110 break;
7111 }
7112 }
7113 }
7114
7115 break;
7116
7117 case LWPNANGULAR:
7118 if(0!=(s=checkLWpn(ri->lwpn,"Angular")))
7119 ret=((weapon*)(s))->angular*10000;
7120
7121 break;
7122
7123 case LWPNAUTOROTATE:
7124 if(0!=(s=checkLWpn(ri->lwpn,"AutoRotate")))
7125 ret=((weapon*)(s))->autorotate*10000;
7126
7127 break;
7128
7129 case LWPNBEHIND:
7130 if(0!=(s=checkLWpn(ri->lwpn,"Behind")))
7131 ret=((weapon*)(s))->behind*10000;
7132
7133 break;
7134
7135 case LWPNDRAWTYPE:
7136 if(0!=(s=checkLWpn(ri->lwpn,"DrawStyle")))
7137 ret=((weapon*)(s))->drawstyle*10000;
7138
7139 break;
7140
7141 case LWPNPOWER:
7142
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 85829 times.
85830 if(0!=(s=checkLWpn(ri->lwpn,"Damage")))
7143 85829 ret=((weapon*)(s))->power*10000;
7144
7145 85830 break;
7146 /*
7147 case LWPNRANGE:
7148 if(0!=(s=checkLWpn(ri->lwpn,"Range")))
7149 ret=((weapon*)(s))->scriptrange*10000;
7150
7151 break;
7152 */
7153 case LWPNDEAD:
7154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1122 times.
1122 if(0!=(s=checkLWpn(ri->lwpn,"DeadState")))
7155 1122 ret=((weapon*)(s))->dead*10000;
7156
7157 1122 break;
7158
7159 case LWPNID:
7160
2/2
✓ Branch 0 taken 13757 times.
✓ Branch 1 taken 3771488 times.
3785245 if(0!=(s=checkLWpn(ri->lwpn,"ID")))
7161 3771488 ret=((weapon*)(s))->id*10000;
7162
7163 3785245 break;
7164
7165 case LWPNTILE:
7166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49772 times.
49772 if(0!=(s=checkLWpn(ri->lwpn,"Tile")))
7167 49772 ret=((weapon*)(s))->tile*10000;
7168
7169 49772 break;
7170
7171 case LWPNSCRIPTTILE:
7172 if(0!=(s=checkLWpn(ri->lwpn,"ScriptTile")))
7173 ret=((weapon*)(s))->scripttile*10000;
7174
7175 break;
7176
7177 case LWPNSCRIPTFLIP:
7178 if(0!=(s=checkLWpn(ri->lwpn,"ScriptFlip")))
7179 ret=((weapon*)(s))->scriptflip*10000;
7180
7181 break;
7182
7183 case LWPNCSET:
7184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49794 times.
49794 if(0!=(s=checkLWpn(ri->lwpn,"CSet")))
7185 49794 ret=((weapon*)(s))->cs*10000;
7186
7187 49794 break;
7188
7189 case LWPNFLASHCSET:
7190 if(0!=(s=checkLWpn(ri->lwpn,"FlashCSet")))
7191 ret=(((weapon*)(s))->o_cset>>4)*10000;
7192
7193 break;
7194
7195 case LWPNFRAMES:
7196
1/2
✓ Branch 0 taken 3289 times.
✗ Branch 1 not taken.
3289 if(0!=(s=checkLWpn(ri->lwpn,"NumFrames")))
7197 3289 ret=((weapon*)(s))->frames*10000;
7198
7199 3289 break;
7200
7201 case LWPNFRAME:
7202 if(0!=(s=checkLWpn(ri->lwpn,"Frame")))
7203 ret=((weapon*)(s))->aframe*10000;
7204
7205 break;
7206
7207 case LWPNASPEED:
7208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3289 times.
3289 if(0!=(s=checkLWpn(ri->lwpn,"ASpeed")))
7209 3289 ret=((weapon*)(s))->o_speed*10000;
7210
7211 3289 break;
7212
7213 case LWPNFLASH:
7214 if(0!=(s=checkLWpn(ri->lwpn,"Flash")))
7215 ret=((weapon*)(s))->flash*10000;
7216
7217 break;
7218
7219 case LWPNFLIP:
7220 if(0!=(s=checkLWpn(ri->lwpn,"Flip")))
7221 ret=((weapon*)(s))->flip*10000;
7222
7223 break;
7224
7225 case LWPNCOUNT:
7226 1094820 ret=Lwpns.Count()*10000;
7227 1094820 break;
7228
7229 case LWPNEXTEND:
7230 if(0!=(s=checkLWpn(ri->lwpn,"Extend")))
7231 ret=((weapon*)(s))->extend*10000;
7232
7233 break;
7234
7235 case LWPNOTILE:
7236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 830567 times.
830567 if(0!=(s=checkLWpn(ri->lwpn,"OriginalTile")))
7237 830567 ret=((weapon*)(s))->o_tile*10000;
7238
7239 830567 break;
7240
7241 case LWPNOCSET:
7242 if(0!=(s=checkLWpn(ri->lwpn,"OriginalCSet")))
7243 ret=(((weapon*)(s))->o_cset&15)*10000;
7244
7245 break;
7246
7247 case LWPNHXOFS:
7248
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 121386 times.
135142 if(0!=(s=checkLWpn(ri->lwpn,"HitXOffset")))
7249 121386 ret=(((weapon*)(s))->hxofs)*10000;
7250
7251 135142 break;
7252
7253 case LWPNHYOFS:
7254
2/2
✓ Branch 0 taken 118638 times.
✓ Branch 1 taken 13756 times.
132394 if(0!=(s=checkLWpn(ri->lwpn,"HitYOffset")))
7255 118638 ret=(((weapon*)(s))->hyofs)*10000;
7256
7257 132394 break;
7258
7259 case LWPNXOFS:
7260 if(0!=(s=checkLWpn(ri->lwpn,"DrawXOffset")))
7261 ret=((int32_t)(((weapon*)(s))->xofs))*10000;
7262
7263 break;
7264
7265 case LWPNYOFS:
7266 if(0!=(s=checkLWpn(ri->lwpn,"DrawYOffset")))
7267 ret=((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))*10000;
7268
7269 break;
7270
7271 case LWPNSHADOWXOFS:
7272 if(0!=(s=checkLWpn(ri->lwpn,"ShadowXOffset")))
7273 ret=((int32_t)(((weapon*)(s))->shadowxofs))*10000;
7274
7275 break;
7276
7277 case LWPNSHADOWYOFS:
7278 if(0!=(s=checkLWpn(ri->lwpn,"ShadowYOffset")))
7279 ret=((int32_t)(((weapon*)(s))->shadowyofs))*10000;
7280
7281 break;
7282
7283 case LWPNTOTALDYOFFS:
7284 if(0!=(s=checkLWpn(ri->lwpn,"TotalDYOffset")))
7285 ret = ((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))
7286 + ((((weapon*)(s))->switch_hooked && Hero.switchhookstyle == swRISE)
7287 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0)) * 10000;
7288 break;
7289
7290 case LWPNZOFS:
7291 if(0!=(s=checkLWpn(ri->lwpn,"DrawZOffset")))
7292 ret=((int32_t)(((weapon*)(s))->zofs))*10000;
7293
7294 break;
7295
7296 case LWPNHXSZ:
7297
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 119380 times.
133136 if(0!=(s=checkLWpn(ri->lwpn,"HitWidth")))
7298 119380 ret=(((weapon*)(s))->hit_width)*10000;
7299
7300 133136 break;
7301
7302 case LWPNHYSZ:
7303
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 121335 times.
135091 if(0!=(s=checkLWpn(ri->lwpn,"HitHeight")))
7304 121335 ret=(((weapon*)(s))->hit_height)*10000;
7305
7306 135091 break;
7307
7308 case LWPNHZSZ:
7309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27874 times.
27874 if(0!=(s=checkLWpn(ri->lwpn,"HitZHeight")))
7310 27874 ret=(((weapon*)(s))->hzsz)*10000;
7311
7312 27874 break;
7313
7314 case LWPNTXSZ:
7315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25249 times.
25249 if(0!=(s=checkLWpn(ri->lwpn,"TileWidth")))
7316 25249 ret=(((weapon*)(s))->txsz)*10000;
7317
7318 25249 break;
7319
7320 case LWPNTYSZ:
7321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25249 times.
25249 if(0!=(s=checkLWpn(ri->lwpn,"TileHeight")))
7322 25249 ret=(((weapon*)(s))->tysz)*10000;
7323
7324 25249 break;
7325
7326 case LWPNMISCD:
7327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1553638 times.
1553638 if(0!=(s=checkLWpn(ri->lwpn,"Misc")))
7328 {
7329 1553638 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
7330 1553638 ret=(((weapon*)(s))->miscellaneous[a]);
7331 1553638 }
7332
7333 1553638 break;
7334
7335 case LWPNCOLLDET:
7336
1/2
✓ Branch 0 taken 4320 times.
✗ Branch 1 not taken.
4320 if(0!=(s=checkLWpn(ri->lwpn,"CollDetection")))
7337 4320 ret=(((weapon*)(s))->scriptcoldet)*10000;
7338
7339 4320 break;
7340
7341 case LWPNENGINEANIMATE:
7342 if(0!=(s=checkLWpn(ri->lwpn,"Animation")))
7343 ret=(((weapon*)(s))->do_animation)*10000;
7344
7345 break;
7346
7347 case LWPNPARENT:
7348 if(0!=(s=checkLWpn(ri->lwpn,"Parent")))
7349 ret=(((weapon*)(s))->parentitem)*10000;
7350
7351 break;
7352
7353 case LWPNLEVEL:
7354 if(0!=(s=checkLWpn(ri->lwpn,"Level")))
7355 ret=(((weapon*)(s))->type)*10000;
7356
7357 break;
7358
7359 case LWPNSCRIPT:
7360 if(0!=(s=checkLWpn(ri->lwpn,"Script")))
7361 ret=(((weapon*)(s))->weaponscript)*10000;
7362
7363 break;
7364
7365 case LWPNUSEWEAPON:
7366
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(0!=(s=checkLWpn(ri->lwpn,"Weapon")))
7367 179 ret=(((weapon*)(s))->useweapon)*10000;
7368
7369 179 break;
7370
7371 case LWPNUSEDEFENCE:
7372 if(0!=(s=checkLWpn(ri->lwpn,"Defense")))
7373 ret=(((weapon*)(s))->usedefence)*10000;
7374
7375 break;
7376
7377 case LWPNINITD:
7378 {
7379 180 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
7380
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(0!=(s=checkLWpn(ri->lwpn,"InitD[]")))
7381 {
7382 180 ret=(((weapon*)(s))->weap_initd[a]);
7383 180 }
7384 180 break;
7385 }
7386
7387 case LWEAPONSCRIPTUID:
7388 if(0!=(s=checkLWpn(ri->lwpn,"ScriptUID")))
7389 ret=(((weapon*)(s))->script_UID); //literal, not *10000
7390
7391 break;
7392
7393 case LWPNROTATION:
7394 if ( get_qr(qr_OLDSPRITEDRAWS) )
7395 {
7396 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
7397 "lweapon->Rotation");
7398 ret = -1; break;
7399 }
7400 if(0!=(s=checkLWpn(ri->lwpn,"Rotation")))
7401 ret=((weapon*)(s))->rotation*10000;
7402
7403 break;
7404
7405 case LWPNFALLCLK:
7406 if(0!=(s=checkLWpn(ri->lwpn,"Falling")))
7407 {
7408 ret = ((weapon*)(s))->fallclk * 10000;
7409 }
7410 break;
7411
7412 case LWPNFALLCMB:
7413 if(0!=(s=checkLWpn(ri->lwpn,"FallCombo")))
7414 {
7415 ret = ((weapon*)(s))->fallCombo * 10000;
7416 }
7417 break;
7418
7419 case LWPNDROWNCLK:
7420 if(0!=(s=checkLWpn(ri->lwpn,"Drowning")))
7421 {
7422 ret = ((weapon*)(s))->drownclk * 10000;
7423 }
7424 break;
7425
7426 case LWPNDROWNCMB:
7427 if(0!=(s=checkLWpn(ri->lwpn,"DrownCombo")))
7428 {
7429 ret = ((weapon*)(s))->drownCombo * 10000;
7430 }
7431 break;
7432
7433 case LWPNFAKEZ:
7434 if(0!=(s=checkLWpn(ri->lwpn,"FakeZ")))
7435 {
7436 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7437 {
7438 ret=(((weapon*)(s))->fakez).getZLong();
7439 }
7440 else
7441 ret=((int32_t)((weapon*)(s))->fakez)*10000;
7442 }
7443 break;
7444
7445 case LWPNMOVEFLAGS:
7446 {
7447 if(0!=(s=checkLWpn(ri->lwpn,"MoveFlags[]")))
7448 {
7449 int32_t indx = ri->d[rINDEX]/10000;
7450 if(BC::checkBounds(indx, 0, 10, "lweapon->MoveFlags[]") != SH::_NoError)
7451 ret = 0; //false
7452 else
7453 {
7454 //All bits, in order, of a single byte; just use bitwise
7455 ret = (((weapon*)(s))->moveflags & (1<<indx)) ? 10000 : 0;
7456 }
7457 }
7458 break;
7459 }
7460 case LWPNFLAGS:
7461 {
7462 if(0!=(s=checkLWpn(ri->lwpn,"Flags[]")))
7463 {
7464 int32_t indx = ri->d[rINDEX]/10000;
7465 if(BC::checkBounds(indx, 0, WFLAG_MAX, "lweapon->Flags[]") != SH::_NoError)
7466 ret = 0; //false
7467 else
7468 {
7469 //All bits, in order, of a single byte; just use bitwise
7470 ret = (((weapon*)(s))->misc_wflags & (1<<indx)) ? 10000 : 0;
7471 }
7472 }
7473 break;
7474 }
7475
7476 case LWPNGLOWRAD:
7477 if(0!=(s=checkLWpn(ri->lwpn,"LightRadius")))
7478 {
7479 ret = ((weapon*)(s))->glowRad * 10000;
7480 }
7481 break;
7482
7483 case LWPNGLOWSHP:
7484 if(0!=(s=checkLWpn(ri->lwpn,"LightShape")))
7485 {
7486 ret = ((weapon*)(s))->glowShape * 10000;
7487 }
7488 break;
7489
7490 case LWPNUNBL:
7491 if(0!=(s=checkLWpn(ri->lwpn,"Unblockable")))
7492 {
7493 ret = ((weapon*)(s))->unblockable * 10000;
7494 }
7495 break;
7496
7497 case LWPNSHADOWSPR:
7498 if(0!=(s=checkLWpn(ri->lwpn,"ShadowSprite")))
7499 {
7500 ret = ((weapon*)(s))->spr_shadow * 10000;
7501 }
7502 break;
7503 case LWSWHOOKED:
7504 if(0!=(s=checkLWpn(ri->lwpn,"SwitchHooked")))
7505 {
7506 ret = s->switch_hooked ? 10000 : 0;
7507 }
7508 break;
7509 case LWPNTIMEOUT:
7510 if(0!=(s=checkLWpn(ri->lwpn,"Timeout")))
7511 {
7512 ret = ((weapon*)(s))->weap_timeout * 10000;
7513 }
7514 break;
7515 case LWPNDEATHITEM:
7516 if(0!=(s=checkLWpn(ri->lwpn,"DeathItem")))
7517 {
7518 ret = ((weapon*)(s))->death_spawnitem * 10000;
7519 }
7520 break;
7521 case LWPNDEATHDROPSET:
7522 if(0!=(s=checkLWpn(ri->lwpn,"DeathDropset")))
7523 {
7524 ret = ((weapon*)(s))->death_spawndropset * 10000;
7525 }
7526 break;
7527 case LWPNDEATHIPICKUP:
7528 if(0!=(s=checkLWpn(ri->lwpn,"DeathItemPFlags")))
7529 {
7530 ret = ((weapon*)(s))->death_item_pflags * 10000;
7531 }
7532 break;
7533 case LWPNDEATHSPRITE:
7534 if(0!=(s=checkLWpn(ri->lwpn,"DeathSprite")))
7535 {
7536 ret = ((weapon*)(s))->death_sprite * 10000;
7537 }
7538 break;
7539 case LWPNDEATHSFX:
7540 if(0!=(s=checkLWpn(ri->lwpn,"DeathSFX")))
7541 {
7542 ret = ((weapon*)(s))->death_sfx * 10000;
7543 }
7544 break;
7545 case LWPNLIFTLEVEL:
7546 if(0!=(s=checkLWpn(ri->lwpn,"LiftLevel")))
7547 {
7548 ret = ((weapon*)(s))->lift_level * 10000;
7549 }
7550 break;
7551 case LWPNLIFTTIME:
7552 if(0!=(s=checkLWpn(ri->lwpn,"LiftTime")))
7553 {
7554 ret = ((weapon*)(s))->lift_time * 10000;
7555 }
7556 break;
7557 case LWPNLIFTHEIGHT:
7558 if(0!=(s=checkLWpn(ri->lwpn,"LiftHeight")))
7559 {
7560 ret = ((weapon*)(s))->lift_height.getZLong();
7561 }
7562 break;
7563
7564 ///----------------------------------------------------------------------------------------------------//
7565 //EWeapon Variables
7566 case EWPNSCALE:
7567 if ( get_qr(qr_OLDSPRITEDRAWS) )
7568 {
7569 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
7570 "eweapon->Scale");
7571 ret = -1; break;
7572 }
7573 if(0!=(s=checkEWpn(ri->ewpn, "Scale")))
7574 ret=((int32_t)((weapon*)(s))->scale)*100.0;
7575
7576 break;
7577
7578 case EWPNX:
7579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1267145 times.
1267145 if(0!=(s=checkEWpn(ri->ewpn, "X")))
7580 {
7581
2/2
✓ Branch 0 taken 148798 times.
✓ Branch 1 taken 1118347 times.
1267145 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7582 {
7583 148798 ret=(((weapon*)(s))->x).getZLong();
7584 148798 }
7585 else
7586 1118347 ret=((int32_t)((weapon*)(s))->x)*10000;
7587 1267145 }
7588 1267145 break;
7589
7590 case SPRITEMAXEWPN:
7591 {
7592 //No bounds check, as this is a universal function and works from NULL pointers!
7593 ret = Ewpns.getMax() * 10000;
7594 break;
7595 }
7596
7597 case EWPNY:
7598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1266708 times.
1266708 if(0!=(s=checkEWpn(ri->ewpn, "Y")))
7599 {
7600
2/2
✓ Branch 0 taken 148686 times.
✓ Branch 1 taken 1118022 times.
1266708 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7601 {
7602 148686 ret=(((weapon*)(s))->y).getZLong();
7603 148686 }
7604 else
7605 1118022 ret=((int32_t)((weapon*)(s))->y)*10000;
7606 1266708 }
7607 1266708 break;
7608
7609 case EWPNZ:
7610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63485 times.
63485 if(0!=(s=checkEWpn(ri->ewpn, "Z")))
7611 {
7612
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 62878 times.
63485 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7613 {
7614 607 ret=(((weapon*)(s))->z).getZLong();
7615 607 }
7616 else
7617 62878 ret=((int32_t)((weapon*)(s))->z)*10000;
7618 63485 }
7619 63485 break;
7620
7621 case EWPNJUMP:
7622 if(0!=(s=checkEWpn(ri->ewpn, "Jump")))
7623 {
7624 ret = ((weapon*)(s))->fall.getZLong() / -100;
7625 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
7626 }
7627
7628 break;
7629
7630 case EWPNFAKEJUMP:
7631 if(0!=(s=checkEWpn(ri->ewpn, "FakeJump")))
7632 {
7633 ret = ((weapon*)(s))->fakefall.getZLong() / -100;
7634 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
7635 }
7636
7637 break;
7638
7639 case EWPNDIR:
7640
1/2
✓ Branch 0 taken 22679 times.
✗ Branch 1 not taken.
22679 if(0!=(s=checkEWpn(ri->ewpn, "Dir")))
7641 22679 ret=((weapon*)(s))->dir*10000;
7642
7643 22679 break;
7644
7645 case EWPNLEVEL:
7646 if(0!=(s=checkEWpn(ri->ewpn, "Level")))
7647 ret=((weapon*)(s))->type*10000;
7648
7649 break;
7650
7651 case EWPNGRAVITY:
7652 if(0!=(s=checkEWpn(ri->ewpn, "Gravity")))
7653 ret=((((weapon*)(s))->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0);
7654
7655 break;
7656
7657 case EWPNSTEP:
7658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362690 times.
362690 if(0!=(s=checkEWpn(ri->ewpn, "Step")))
7659 {
7660
3/4
✓ Branch 0 taken 362528 times.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 362528 times.
✗ Branch 3 not taken.
362690 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
7661 {
7662 362690 ret=((weapon*)s)->step.getZLong() * 100;
7663 362690 }
7664 //old, buggy code replication, round two: Go! -Z
7665 //else ret = ( ( ( ((weapon*)s)->step ) * 100.0 ).getZLong() );
7666 //old, buggy code replication, round FOUR: Go! -Z
7667 else ret = (int32_t)((float)((weapon*)s)->step * 1000000.0);
7668 362690 }
7669 //else
7670 //{
7671 //old, buggy code replication, round THREE: Go! -Z
7672 // double tmp = ( ((weapon*)s)->step.getFloat() ) * 1000000.0;
7673 // ret = int32_t(tmp);
7674 //}
7675 362690 break;
7676
7677 case EWPNANGLE:
7678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373525 times.
373525 if(0!=(s=checkEWpn(ri->ewpn,"Angle")))
7679 373525 ret=(int32_t)(((weapon*)(s))->angle*10000);
7680
7681 373525 break;
7682
7683 case EWPNDEGANGLE:
7684 if(0!=(s=checkEWpn(ri->ewpn,"DegAngle")))
7685 {
7686 ret=(int32_t)(((weapon*)(s))->angle*(180.0 / PI)*10000);
7687 }
7688
7689 break;
7690
7691 case EWPNVX:
7692 if(0!=(s=checkEWpn(ri->ewpn,"Vx")))
7693 {
7694 if (((weapon*)(s))->angular)
7695 ret = int32_t(zc::math::Cos(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
7696 else
7697 {
7698 switch(NORMAL_DIR(((weapon*)(s))->dir))
7699 {
7700 case l_up:
7701 case l_down:
7702 case left:
7703 ret = int32_t(-10000.0*((weapon*)s)->step);
7704 break;
7705 case r_up:
7706 case r_down:
7707 case right:
7708 ret = int32_t(10000.0*((weapon*)s)->step);
7709 break;
7710
7711 default:
7712 ret = 0;
7713 break;
7714 }
7715 }
7716 }
7717
7718 break;
7719
7720 case EWPNVY:
7721 if(0!=(s=checkEWpn(ri->ewpn,"Vy")))
7722 {
7723 if (((weapon*)(s))->angular)
7724 ret = int32_t(zc::math::Sin(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
7725 else
7726 {
7727 switch(NORMAL_DIR(((weapon*)(s))->dir))
7728 {
7729 case l_up:
7730 case r_up:
7731 case up:
7732 ret = int32_t(-10000.0*((weapon*)s)->step);
7733 break;
7734 case l_down:
7735 case r_down:
7736 case down:
7737 ret = int32_t(10000.0*((weapon*)s)->step);
7738 break;
7739
7740 default:
7741 ret = 0;
7742 break;
7743 }
7744 }
7745 }
7746
7747 break;
7748
7749
7750 case EWPNANGULAR:
7751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68688 times.
68688 if(0!=(s=checkEWpn(ri->ewpn,"Angular")))
7752 68688 ret=((weapon*)(s))->angular*10000;
7753
7754 68688 break;
7755
7756 case EWPNAUTOROTATE:
7757 if(0!=(s=checkEWpn(ri->ewpn,"AutoRotate")))
7758 ret=((weapon*)(s))->autorotate*10000;
7759
7760 break;
7761
7762 case EWPNBEHIND:
7763 if(0!=(s=checkEWpn(ri->ewpn,"Behind")))
7764 ret=((weapon*)(s))->behind*10000;
7765
7766 break;
7767
7768 case EWPNDRAWTYPE:
7769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46359 times.
46359 if(0!=(s=checkEWpn(ri->ewpn,"DrawStyle")))
7770 46359 ret=((weapon*)(s))->drawstyle*10000;
7771
7772 46359 break;
7773
7774 case EWPNPOWER:
7775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90188 times.
90188 if(0!=(s=checkEWpn(ri->ewpn,"Damage")))
7776 90188 ret=((weapon*)(s))->power*10000;
7777
7778 90188 break;
7779
7780 case EWPNDEAD:
7781
1/2
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
154 if(0!=(s=checkEWpn(ri->ewpn,"DeadState")))
7782 154 ret=((weapon*)(s))->dead*10000;
7783
7784 154 break;
7785
7786 case EWPNID:
7787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2150394 times.
2150394 if(0!=(s=checkEWpn(ri->ewpn,"ID")))
7788 2150394 ret=((weapon*)(s))->id*10000;
7789
7790 2150394 break;
7791
7792 case EWPNTILE:
7793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106032 times.
106032 if(0!=(s=checkEWpn(ri->ewpn,"Tile")))
7794 106032 ret=((weapon*)(s))->tile*10000;
7795
7796 106032 break;
7797
7798 case EWPNSCRIPTTILE:
7799 if(0!=(s=checkEWpn(ri->ewpn,"ScriptTile")))
7800 ret=((weapon*)(s))->scripttile*10000;
7801
7802 break;
7803
7804 case EWPNSCRIPTFLIP:
7805 if(0!=(s=checkEWpn(ri->ewpn,"ScriptFlip")))
7806 ret=((weapon*)(s))->scriptflip*10000;
7807
7808 break;
7809
7810 case EWPNCSET:
7811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24909 times.
24909 if(0!=(s=checkEWpn(ri->ewpn,"CSet")))
7812 24909 ret=((weapon*)(s))->cs*10000;
7813
7814 24909 break;
7815
7816 case EWPNFLASHCSET:
7817 if(0!=(s=checkEWpn(ri->ewpn,"FlashCSet")))
7818 ret=(((weapon*)(s))->o_cset>>4)*10000;
7819
7820 break;
7821
7822 case EWPNFRAMES:
7823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(0!=(s=checkEWpn(ri->ewpn,"NumFrames")))
7824 70 ret=((weapon*)(s))->frames*10000;
7825
7826 70 break;
7827
7828 case EWPNFRAME:
7829 if(0!=(s=checkEWpn(ri->ewpn,"Frame")))
7830 ret=((weapon*)(s))->aframe*10000;
7831
7832 break;
7833
7834 case EWPNASPEED:
7835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(0!=(s=checkEWpn(ri->ewpn,"ASpeed")))
7836 70 ret=((weapon*)(s))->o_speed*10000;
7837
7838 70 break;
7839
7840 case EWPNFLASH:
7841 if(0!=(s=checkEWpn(ri->ewpn,"Flash")))
7842 ret=((weapon*)(s))->flash*10000;
7843
7844 break;
7845
7846 case EWPNFLIP:
7847 if(0!=(s=checkEWpn(ri->ewpn,"Flip")))
7848 ret=((weapon*)(s))->flip*10000;
7849
7850 break;
7851
7852 case EWPNROTATION:
7853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 if ( get_qr(qr_OLDSPRITEDRAWS) )
7854 {
7855 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
7856 "eweapon->Rotation");
7857 break;
7858 }
7859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 if(0!=(s=checkEWpn(ri->ewpn,"Rotation")))
7860 218 ret=((weapon*)(s))->rotation*10000;
7861
7862 218 break;
7863
7864 case EWPNCOUNT:
7865 1913328 ret=Ewpns.Count()*10000;
7866 1913328 break;
7867
7868 case EWPNEXTEND:
7869 if(0!=(s=checkEWpn(ri->ewpn,"Extend")))
7870 ret=((weapon*)(s))->extend*10000;
7871
7872 break;
7873
7874 case EWPNOTILE:
7875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2925 times.
2925 if(0!=(s=checkEWpn(ri->ewpn,"OriginalTile")))
7876 2925 ret=((weapon*)(s))->o_tile*10000;
7877
7878 2925 break;
7879
7880 case EWPNOCSET:
7881 if(0!=(s=checkEWpn(ri->ewpn,"OriginalCSet")))
7882 ret=(((weapon*)(s))->o_cset&15)*10000;
7883
7884 break;
7885
7886 case EWPNHXOFS:
7887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65540 times.
65540 if(0!=(s=checkEWpn(ri->ewpn,"HitXOffset")))
7888 65540 ret=(((weapon*)(s))->hxofs)*10000;
7889
7890 65540 break;
7891
7892 case EWPNHYOFS:
7893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65540 times.
65540 if(0!=(s=checkEWpn(ri->ewpn,"HitYOffset")))
7894 65540 ret=(((weapon*)(s))->hyofs)*10000;
7895
7896 65540 break;
7897
7898 case EWPNXOFS:
7899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(0!=(s=checkEWpn(ri->ewpn,"DrawXOffset")))
7900 8 ret=((int32_t)(((weapon*)(s))->xofs))*10000;
7901
7902 8 break;
7903
7904 case EWPNYOFS:
7905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(0!=(s=checkEWpn(ri->ewpn,"DrawYOffset")))
7906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))*10000;
7907
7908 96 break;
7909
7910 case EWPNSHADOWXOFS:
7911 if(0!=(s=checkEWpn(ri->ewpn,"ShadowXOffset")))
7912 ret=((int32_t)(((weapon*)(s))->shadowxofs))*10000;
7913
7914 break;
7915
7916 case EWPNSHADOWYOFS:
7917 if(0!=(s=checkEWpn(ri->ewpn,"ShadowYOffset")))
7918 ret=((int32_t)(((weapon*)(s))->shadowyofs))*10000;
7919
7920 break;
7921 case EWPNTOTALDYOFFS:
7922 if(0!=(s=checkLWpn(ri->ewpn,"TotalDYOffset")))
7923 ret = ((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))
7924 + ((((weapon*)(s))->switch_hooked && Hero.switchhookstyle == swRISE)
7925 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0) * 10000);
7926 break;
7927
7928 case EWPNZOFS:
7929 if(0!=(s=checkEWpn(ri->ewpn,"DrawZOffset")))
7930 ret=((int32_t)(((weapon*)(s))->zofs))*10000;
7931
7932 break;
7933
7934 case EWPNHXSZ:
7935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62523 times.
62523 if(0!=(s=checkEWpn(ri->ewpn,"HitWidth")))
7936 62523 ret=(((weapon*)(s))->hit_width)*10000;
7937
7938 62523 break;
7939
7940 case EWPNHYSZ:
7941
1/2
✓ Branch 0 taken 62523 times.
✗ Branch 1 not taken.
62523 if(0!=(s=checkEWpn(ri->ewpn,"HitHeight")))
7942 62523 ret=(((weapon*)(s))->hit_height)*10000;
7943
7944 62523 break;
7945
7946 case EWPNHZSZ:
7947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12470 times.
12470 if(0!=(s=checkEWpn(ri->ewpn,"HitZHeight")))
7948 12470 ret=(((weapon*)(s))->hzsz)*10000;
7949
7950 12470 break;
7951
7952 case EWPNTXSZ:
7953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24497 times.
24497 if(0!=(s=checkEWpn(ri->ewpn,"TileWidth")))
7954 24497 ret=(((weapon*)(s))->txsz)*10000;
7955
7956 24497 break;
7957
7958 case EWPNTYSZ:
7959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24497 times.
24497 if(0!=(s=checkEWpn(ri->ewpn,"TileHeight")))
7960 24497 ret=(((weapon*)(s))->tysz)*10000;
7961
7962 24497 break;
7963
7964 case EWPNMISCD:
7965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13780500 times.
13780500 if(0!=(s=checkEWpn(ri->ewpn,"Misc")))
7966 {
7967 13780500 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
7968 13780500 ret=(((weapon*)(s))->miscellaneous[a]);
7969 13780500 }
7970
7971 13780500 break;
7972
7973 case EWPNCOLLDET:
7974 if(0!=(s=checkEWpn(ri->ewpn,"CollDetection")))
7975 ret=(((weapon*)(s))->scriptcoldet)*10000;
7976
7977 break;
7978
7979 case EWPNENGINEANIMATE:
7980 if(0!=(s=checkEWpn(ri->ewpn,"Animation")))
7981 ret=(((weapon*)(s))->do_animation)*10000;
7982
7983 break;
7984
7985 case EWPNPARENT:
7986 if(0!=(s=checkEWpn(ri->ewpn, "Parent")))
7987 ret= ((get_qr(qr_OLDEWPNPARENT)) ? (((weapon*)(s))->parentid)*10000 : (((weapon*)(s))->parentid));
7988
7989 break;
7990
7991 case EWEAPONSCRIPTUID:
7992 if(0!=(s=checkEWpn(ri->ewpn, "ScriptUID")))
7993 ret=(((weapon*)(s))->script_UID); //literal, not *10000
7994
7995 break;
7996
7997 case EWPNPARENTUID:
7998 if(0!=(s=checkEWpn(ri->ewpn, "ParentUID")))
7999 ret=(((weapon*)(s))->parent_script_UID); //literal, not *10000
8000
8001 break;
8002
8003 case EWPNSCRIPT:
8004 if(0!=(s=checkEWpn(ri->ewpn,"Script")))
8005 ret=(((weapon*)(s))->weaponscript)*10000;
8006
8007 break;
8008
8009 case EWPNINITD:
8010 {
8011 16680 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
8012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16680 times.
16680 if(0!=(s=checkEWpn(ri->ewpn,"InitD[]")))
8013 {
8014 16680 ret=(((weapon*)(s))->weap_initd[a]);
8015 16680 }
8016 16680 break;
8017 }
8018
8019 case EWPNFALLCLK:
8020 if(0!=(s=checkEWpn(ri->ewpn,"Falling")))
8021 {
8022 ret = ((weapon*)(s))->fallclk * 10000;
8023 }
8024 break;
8025
8026 case EWPNFALLCMB:
8027 if(0!=(s=checkEWpn(ri->ewpn,"FallCombo")))
8028 {
8029 ret = ((weapon*)(s))->fallCombo * 10000;
8030 }
8031 break;
8032
8033 case EWPNDROWNCLK:
8034 if(0!=(s=checkEWpn(ri->ewpn,"Drowning")))
8035 {
8036 ret = ((weapon*)(s))->drownclk * 10000;
8037 }
8038 break;
8039
8040 case EWPNDROWNCMB:
8041 if(0!=(s=checkEWpn(ri->ewpn,"DrownCombo")))
8042 {
8043 ret = ((weapon*)(s))->drownCombo * 10000;
8044 }
8045 break;
8046 case EWPNFAKEZ:
8047 if(0!=(s=checkEWpn(ri->ewpn, "FakeZ")))
8048 {
8049 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
8050 {
8051 ret=(((weapon*)(s))->fakez).getZLong();
8052 }
8053 else
8054 ret=((int32_t)((weapon*)(s))->fakez)*10000;
8055 }
8056 break;
8057
8058 case EWPNMOVEFLAGS:
8059 {
8060 if(0!=(s=checkEWpn(ri->ewpn,"MoveFlags[]")))
8061 {
8062 int32_t indx = ri->d[rINDEX]/10000;
8063 if(BC::checkBounds(indx, 0, 10, "eweapon->MoveFlags[]") != SH::_NoError)
8064 ret = 0; //false
8065 else
8066 {
8067 //All bits, in order, of a single byte; just use bitwise
8068 ret = (((weapon*)(s))->moveflags & (1<<indx)) ? 10000 : 0;
8069 }
8070 }
8071 break;
8072 }
8073 case EWPNFLAGS:
8074 {
8075 if(0!=(s=checkEWpn(ri->ewpn,"Flags[]")))
8076 {
8077 int32_t indx = ri->d[rINDEX]/10000;
8078 if(BC::checkBounds(indx, 0, WFLAG_MAX, "eweapon->Flags[]") != SH::_NoError)
8079 ret = 0; //false
8080 else
8081 {
8082 //All bits, in order, of a single byte; just use bitwise
8083 ret = (((weapon*)(s))->misc_wflags & (1<<indx)) ? 10000 : 0;
8084 }
8085 }
8086 break;
8087 }
8088
8089 case EWPNGLOWRAD:
8090 if(0!=(s=checkEWpn(ri->ewpn,"LightRadius")))
8091 {
8092 ret = ((weapon*)(s))->glowRad * 10000;
8093 }
8094 break;
8095
8096 case EWPNGLOWSHP:
8097 if(0!=(s=checkEWpn(ri->ewpn,"LightShape")))
8098 {
8099 ret = ((weapon*)(s))->glowShape * 10000;
8100 }
8101 break;
8102
8103 case EWPNUNBL:
8104 if(0!=(s=checkEWpn(ri->ewpn,"Unblockable")))
8105 {
8106 ret = ((weapon*)(s))->unblockable * 10000;
8107 }
8108 break;
8109
8110 case EWPNSHADOWSPR:
8111 if(0!=(s=checkEWpn(ri->ewpn,"ShadowSprite")))
8112 {
8113 ret = ((weapon*)(s))->spr_shadow * 10000;
8114 }
8115 break;
8116 case EWSWHOOKED:
8117 if(0!=(s=checkEWpn(ri->ewpn,"SwitchHooked")))
8118 {
8119 ret = s->switch_hooked ? 10000 : 0;
8120 }
8121 break;
8122 case EWPNTIMEOUT:
8123 if(0!=(s=checkEWpn(ri->ewpn,"Timeout")))
8124 {
8125 ret = ((weapon*)(s))->weap_timeout * 10000;
8126 }
8127 break;
8128 case EWPNDEATHITEM:
8129 if(0!=(s=checkEWpn(ri->ewpn,"DeathItem")))
8130 {
8131 ret = ((weapon*)(s))->death_spawnitem * 10000;
8132 }
8133 break;
8134 case EWPNDEATHDROPSET:
8135 if(0!=(s=checkEWpn(ri->ewpn,"DeathDropset")))
8136 {
8137 ret = ((weapon*)(s))->death_spawndropset * 10000;
8138 }
8139 break;
8140 case EWPNDEATHIPICKUP:
8141 if(0!=(s=checkEWpn(ri->ewpn,"DeathItemPFlags")))
8142 {
8143 ret = ((weapon*)(s))->death_item_pflags * 10000;
8144 }
8145 break;
8146 case EWPNDEATHSPRITE:
8147 if(0!=(s=checkEWpn(ri->ewpn,"DeathSprite")))
8148 {
8149 ret = ((weapon*)(s))->death_sprite * 10000;
8150 }
8151 break;
8152 case EWPNDEATHSFX:
8153 if(0!=(s=checkEWpn(ri->ewpn,"DeathSFX")))
8154 {
8155 ret = ((weapon*)(s))->death_sfx * 10000;
8156 }
8157 break;
8158 case EWPNLIFTLEVEL:
8159 if(0!=(s=checkEWpn(ri->ewpn,"LiftLevel")))
8160 {
8161 ret = ((weapon*)(s))->lift_level * 10000;
8162 }
8163 break;
8164 case EWPNLIFTTIME:
8165 if(0!=(s=checkEWpn(ri->ewpn,"LiftTime")))
8166 {
8167 ret = ((weapon*)(s))->lift_time * 10000;
8168 }
8169 break;
8170 case EWPNLIFTHEIGHT:
8171 if(0!=(s=checkEWpn(ri->ewpn,"LiftHeight")))
8172 {
8173 ret = ((weapon*)(s))->lift_height.getZLong();
8174 }
8175 break;
8176
8177 /*
8178 case LWEAPONSCRIPTUID:
8179 if(0!=(s=checkLWpn(ri->lwpn,"ScriptUID")))
8180 ret=(((weapon*)(s))->getScriptUID()); //literal, not *10000
8181
8182 break;
8183 case EWEAPONSCRIPTUID:
8184 if(0!=(s=checkLWpn(ri->ewpn,"ScriptUID")))
8185 ret=(((weapon*)(s))->getScriptUID()); //literal, not *10000
8186
8187 break;
8188 */
8189
8190 ///----------------------------------------------------------------------------------------------------//
8191 //Game Info
8192
8193
8194 case GAMEPLAYFIELDOFS:
8195 ret = playing_field_offset*10000;
8196 break;
8197
8198 case GETPIXEL:
8199 ret=FFCore.do_getpixel();
8200 break;
8201
8202
8203 case ZELDAVERSION:
8204 ret = ZC_VERSION; //Do *not* multiply by 10,000!
8205 break;
8206 case ZELDABUILD:
8207 ret = (int32_t)VERSION_BUILD*10000;
8208 break;
8209
8210 case ZSCRIPTVERSION:
8211 {
8212 ret = (FFCore.quest_format[vLastCompile]) * 10000;
8213 break;
8214 }
8215
8216 case ZELDABETATYPE:
8217 {
8218 ret = int32_t(ALPHA_STATE*10000);
8219 break;
8220 }
8221 case ZELDABETA:
8222 {
8223 ret = int32_t(ALPHA_VER*10000);
8224 if(ZC_IS_NIGHTLY) //Nightly 111/112 should return '111.5' not '112'
8225 ret -= 5000;
8226 break;
8227 }
8228 case GAMEDEATHS:
8229 ret=game->get_deaths()*10000;
8230 break;
8231
8232 case GAMECHEAT:
8233 ret=cheat*10000;
8234 break;
8235
8236 case GAMEMAXCHEAT:
8237 ret=maxcheat*10000;
8238 break;
8239
8240 case GAMETIME:
8241 ret=game->get_time();
8242 break;// Can't multiply by 10000 or the maximum result is too big
8243 case ACTIVESSSPEED:
8244 ret=Hero.subscr_speed*10000;
8245 break;// Can't multiply by 10000 or the maximum result is too big
8246
8247 case GAMETIMEVALID:
8248 ret=game->get_timevalid()?10000:0;
8249 break;
8250
8251 case GAMEHASPLAYED:
8252 ret=game->get_hasplayed()?10000:0;
8253 break;
8254
8255 case TYPINGMODE:
8256 ret=FFCore.kb_typing_mode?10000:0;
8257 break;
8258
8259 case SKIPCREDITS:
8260 ret=FFCore.skip_ending_credits?10000:0;
8261 break;
8262
8263 case SKIPF6:
8264 ret=get_qr(qr_NOCONTINUE)?10000:0;
8265 break;
8266
8267 case GAMESTANDALONE:
8268 17 ret=standalone_mode?10000:0;
8269 17 break;
8270
8271 case GAMEGUYCOUNT:
8272 {
8273 26 int32_t mi = (currmap*MAPSCRSNORMAL)+(ri->d[rINDEX]/10000);
8274 26 ret=game->guys[mi]*10000;
8275 }
8276 26 break;
8277
8278 case GAMECONTSCR:
8279 678 ret=game->get_continue_scrn()*10000;
8280 678 break;
8281
8282 case GAMECONTDMAP:
8283 972 ret=game->get_continue_dmap()*10000;
8284 972 break;
8285
8286 case GAMEENTRSCR:
8287 14 ret=lastentrance*10000;
8288 14 break;
8289
8290 case GAMEENTRDMAP:
8291 471 ret=lastentrance_dmap*10000;
8292 471 break;
8293
8294 case GAMECOUNTERD:
8295 4013519 ret=game->get_counter((ri->d[rINDEX])/10000)*10000;
8296 4013519 break;
8297
8298 case GAMEMCOUNTERD:
8299 1586472 ret=game->get_maxcounter((ri->d[rINDEX])/10000)*10000;
8300 1586472 break;
8301
8302 case GAMEDCOUNTERD:
8303 15 ret=game->get_dcounter((ri->d[rINDEX])/10000)*10000;
8304 15 break;
8305
8306 case GAMEGENERICD:
8307 {
8308 16 auto indx = ri->d[rINDEX] / 10000;
8309
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 switch(indx)
8310 {
8311 case genCONTHP:
8312 {
8313 if(!get_qr(qr_SCRIPT_CONTHP_IS_HEARTS) || game->get_cont_percent())
8314 ret = game->get_generic(indx)*10000;
8315 else
8316 ret = (game->get_generic(indx)/game->get_hp_per_heart())*10000;
8317 break;
8318 }
8319 default:
8320 16 ret = game->get_generic(indx)*10000;
8321 16 break;
8322 }
8323 16 break;
8324 }
8325
8326 case GAMEMISC:
8327 {
8328 int32_t indx = ri->d[rINDEX]/10000;
8329 if ( indx < 0 || indx > 31 )
8330 {
8331 ret = -10000;
8332 Z_scripterrlog("Invalud index used to access Game->Misc: %d\n", indx);
8333 }
8334 else
8335 {
8336 ret = QMisc.questmisc[indx]*((get_qr(qr_OLDQUESTMISC)) ? 10000 : 1);
8337 }
8338 break;
8339 }
8340
8341 case GAMEITEMSD:
8342 ret=(game->item[(ri->d[rINDEX])/10000] ? 10000 : 0);
8343 break;
8344 case DISABLEDITEM:
8345 ret = (game->items_off[(ri->d[rINDEX])/10000] ? 10000 : 0);
8346 break;
8347 case GAMESUSPEND:
8348 {
8349 int32_t inx = (ri->d[rINDEX])/10000;
8350 if ( (unsigned) inx > (susptLAST-1) )
8351 {
8352 Z_scripterrlog("Invalid array index [%d] passed to Gme->Suspend[]\n");
8353 }
8354 ret = (( FFCore.system_suspend[inx] ) ? 10000 : 0);
8355 break;
8356 }
8357 case GAMELITEMSD:
8358 2365308 ret=game->lvlitems[(ri->d[rINDEX])/10000]*10000;
8359 2365308 break;
8360 case GAMELSWITCH:
8361 {
8362 int32_t ind = (ri->d[rINDEX])/10000;
8363 if(unsigned(ind) >= MAXLEVELS)
8364 ret = 0;
8365 else ret=game->lvlswitches[ind];
8366 break;
8367 }
8368 case GAMEGSWITCH:
8369 {
8370 int32_t ind = (ri->d[rINDEX])/10000;
8371 if(unsigned(ind) >= NUM_GSWITCHES)
8372 ret = 0;
8373 else ret=game->gswitch_timers[ind]*10000;
8374 break;
8375 }
8376 case GAMEBOTTLEST:
8377 ret=game->get_bottle_slot((ri->d[rINDEX])/10000)*10000;
8378 break;
8379
8380 case GAMELKEYSD:
8381 561132 ret=game->lvlkeys[(ri->d[rINDEX])/10000]*10000;
8382 561132 break;
8383
8384 case TANGOARR:
8385 {
8386 int32_t inx = (ri->d[rINDEX])/10000;
8387 if ( ((unsigned)inx) > 255 )
8388 {
8389 Z_scripterrlog("Invalid index %d supplied to Game->Tango[].\n", inx);
8390 ret = -10000;
8391 break;
8392 }
8393 else
8394 {
8395 ret=FFCore.TangoArray[inx]*10000;
8396 break;
8397 }
8398 }
8399 case GHOSTARR:
8400 {
8401 int32_t inx = (ri->d[rINDEX])/10000;
8402 if ( ((unsigned)inx) > 255 )
8403 {
8404 Z_scripterrlog("Invalid index %d supplied to Game->Ghost[].\n", inx);
8405 ret = -10000;
8406 break;
8407 }
8408 else
8409 {
8410 ret=FFCore.GhostArray[inx]*10000;
8411 break;
8412 }
8413 }
8414 case STDARR:
8415 {
8416 int32_t inx = (ri->d[rINDEX])/10000;
8417 if ( ((unsigned)inx) > 255 )
8418 {
8419 Z_scripterrlog("Invalid index %d supplied to Game->STD[].\n", inx);
8420 ret = -10000;
8421 break;
8422 }
8423 else
8424 {
8425 ret=FFCore.StdArray[inx]*10000;
8426 break;
8427 }
8428 }
8429
8430 case GAMEMISCSPR:
8431 {
8432 int32_t inx = (ri->d[rINDEX])/10000;
8433 if ( ((unsigned)inx) > sprMAX )
8434 {
8435 Z_scripterrlog("Invalid index %d supplied to Game->MiscSprites[].\n", inx);
8436 ret = -10000;
8437 }
8438 else
8439 {
8440 ret = QMisc.sprites[inx] * 10000;
8441 }
8442 break;
8443 }
8444 case GAMEMISCSFX:
8445 {
8446 int32_t inx = (ri->d[rINDEX])/10000;
8447 if ( ((unsigned)inx) > sfxMAX )
8448 {
8449 Z_scripterrlog("Invalid index %d supplied to Game->MiscSFX[].\n", inx);
8450 ret = -10000;
8451 }
8452 else
8453 {
8454 ret = QMisc.miscsfx[inx] * 10000;
8455 }
8456 break;
8457 }
8458 case GAMEOVERRIDEITEMS:
8459 {
8460 int32_t ind = (ri->d[rINDEX])/10000;
8461 if(unsigned(ind) >= itype_max)
8462 {
8463 Z_scripterrlog("Invalid index %d supplied to Game->OverrideItems[].\n", ind);
8464 ret = -20000;
8465 }
8466 else ret = game->OverrideItems[ind] * 10000;
8467 break;
8468 }
8469 case GAMEEVENTDATA:
8470 {
8471 int32_t inx = (ri->d[rINDEX])/10000;
8472 ret = 0;
8473 if ( ((unsigned)inx) < FFCore.eventData.size() )
8474 {
8475 ret = FFCore.eventData[inx];
8476 }
8477 break;
8478 }
8479 case GAMEMOUSECURSOR:
8480 {
8481 ret = game_mouse_index*10000;
8482 break;
8483 }
8484 case GAMETRIGGROUPS:
8485 {
8486 int32_t ind = (ri->d[rINDEX])/10000;
8487 if(unsigned(ind)>255)
8488 Z_scripterrlog("Invalid index %d supplied to Game->TrigGroups[]\n",ind);
8489 ret = cpos_trig_group_count(ind)*10000;
8490 break;
8491 }
8492
8493 case GAMEGRAVITY:
8494 {
8495 int32_t indx = ri->d[rINDEX]/10000;
8496 if ( ((unsigned)indx) > 2 )
8497 //if(indx < 0 || indx > 2)
8498 {
8499 ret = -10000;
8500 Z_scripterrlog("Invalid index used to access Game->Gravity[]: %d\n", indx);
8501 }
8502 else
8503 {
8504 switch(indx)
8505 {
8506 case 0: //Gravity Strength
8507 ret = zinit.gravity;
8508 break;
8509 case 1: //Terminal Velocity
8510 ret = zinit.terminalv * 100;
8511 break;
8512 case 2: //Sprite Layer Threshold
8513 ret = zinit.jump_hero_layer_threshold * 10000;
8514 break;
8515 }
8516 }
8517 break;
8518 }
8519
8520 case GAMESCROLLING:
8521 {
8522 191517 int32_t indx = ri->d[rINDEX]/10000;
8523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 191517 times.
191517 if ( ((unsigned)indx) >= SZ_SCROLLDATA )
8524 //if(indx < 0 || indx >= SZ_SCROLLDATA)
8525 {
8526 Z_scripterrlog("Invalid index used to access Game->Scrolling[]: %d\n", indx);
8527 }
8528 else
8529 {
8530 191517 ret = FFCore.ScrollingData[indx] * 10000L;
8531 }
8532 191517 break;
8533 }
8534
8535
8536 case SCREENSTATED:
8537 {
8538 1218351 int32_t mi = get_mi(MAPSCR_TEMP0);
8539
1/2
✓ Branch 0 taken 1218351 times.
✗ Branch 1 not taken.
1218351 if(mi<0) {ret = 0;break;}
8540 1218351 ret=((game->maps[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
8541 }
8542 1218351 break;
8543 case SCREENEXSTATED:
8544 {
8545 int32_t mi = get_mi(MAPSCR_TEMP0);
8546 if(mi<0) {ret = 0;break;}
8547 ret=((game->xstates[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
8548 }
8549 break;
8550 case SCREENLENSSHOWS:
8551 {
8552 int ind = ri->d[rINDEX]/10000;
8553 if(ind < 0 || ind > 6)
8554 Z_scripterrlog("Bad index Screen->LensShows[%d]\n",ind);
8555 else ret = (tmpscr->lens_show & (1<<ind)) ? 10000 : 0;
8556 break;
8557 }
8558 case SCREENLENSHIDES:
8559 {
8560 int ind = ri->d[rINDEX]/10000;
8561 if(ind < 0 || ind > 6)
8562 Z_scripterrlog("Bad index Screen->LensHides[%d]\n",ind);
8563 else ret = (tmpscr->lens_hide & (1<<ind)) ? 10000 : 0;
8564 break;
8565 }
8566 case SCREENSCRDATASIZE:
8567 {
8568 auto mi = get_total_mi();
8569 if(mi < 0) break;
8570 ret = 10000*game->scriptDataSize(mi);
8571 break;
8572 }
8573 case SCREENSCRDATA:
8574 {
8575 auto mi = get_total_mi();
8576 if(mi < 0) break;
8577 size_t indx = ri->d[rINDEX]/10000;
8578 if(indx >= game->scriptDataSize(mi))
8579 {
8580 Z_scripterrlog("Invalid index passed to Screen->Data[]: %d\n", indx);
8581 break;
8582 }
8583 ret = game->screen_data[mi][indx];
8584 break;
8585 }
8586
8587 case DISTANCE:
8588 {
8589 225833 double x1 = double(ri->d[rSFTEMP] / 10000.0);
8590 225833 double y1 = double(ri->d[rINDEX] / 10000.0);
8591 225833 double x2 = double(ri->d[rINDEX2] / 10000.0);
8592 225833 double y2 = double(ri->d[rEXP1] / 10000.0);
8593
8594
8595
8596 225833 int32_t result = FFCore.Distance(x1, y1, x2, y2);
8597 225833 ret = (result);
8598
8599 225833 break;
8600 }
8601 case LONGDISTANCE:
8602 {
8603 double x1 = double(ri->d[rSFTEMP]);
8604 double y1 = double(ri->d[rINDEX]);
8605 double x2 = double(ri->d[rINDEX2]);
8606 double y2 = double(ri->d[rEXP1]);
8607
8608
8609
8610 int32_t result = FFCore.LongDistance(x1, y1, x2, y2);
8611 ret = (result);
8612
8613 break;
8614 }
8615
8616 case DISTANCESCALE:
8617 {
8618 double x1 = (double)(ri->d[rSFTEMP] / 10000.0);
8619 zprint2("x1 is: %f\n", x1);
8620 double y1 = (double)(ri->d[rINDEX] / 10000.0);
8621 zprint2("y1 is: %f\n", y1);
8622 double x2 = (double)(ri->d[rINDEX2] / 10000.0);
8623 zprint2("x2 is: %f\n", x2);
8624 double y2 = (double)(ri->d[rEXP1] / 10000.0);
8625 zprint2("y2 is: %f\n", y2);
8626
8627 int32_t scale = (ri->d[rWHAT_NO_7]/10000);
8628 zprint2("Scale is: %d\n", scale);
8629
8630 if ( !scale ) scale = 10000;
8631 int32_t result = FFCore.Distance(x1, y1, x2, y2, scale);
8632 ret = (result);
8633
8634 break;
8635 }
8636 case LONGDISTANCESCALE:
8637 {
8638 double x1 = (double)(ri->d[rSFTEMP]);
8639 zprint2("x1 is: %f\n", x1);
8640 double y1 = (double)(ri->d[rINDEX]);
8641 zprint2("y1 is: %f\n", y1);
8642 double x2 = (double)(ri->d[rINDEX2]);
8643 zprint2("x2 is: %f\n", x2);
8644 double y2 = (double)(ri->d[rEXP1]);
8645 zprint2("y2 is: %f\n", y2);
8646
8647 int32_t scale = (ri->d[rWHAT_NO_7]);
8648 zprint2("Scale is: %d\n", scale);
8649
8650 if ( !scale ) scale = 1;
8651 int32_t result = FFCore.LongDistance(x1, y1, x2, y2, scale);
8652 ret = (result);
8653
8654 break;
8655 }
8656
8657 case SCREENSTATEDD:
8658 {
8659 // Gah! >:( Screen state is stored in game->maps, which uses 128 screens per map,
8660 // but the compiler multiplies the map number by 136, so it has to be corrected here.
8661 // Yeah, the compiler could be fixed, but that wouldn't cover existing quests...
8662 18739404 int32_t mi = ri->d[rINDEX] / 10000;
8663 18739404 mi -= 8*((ri->d[rINDEX] / 10000) / MAPSCRS);
8664
8665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18739404 times.
18739404 if(BC::checkMapID(mi>>7, "Game->GetScreenState") == SH::_NoError)
8666 18739404 ret=(game->maps[mi] >> (ri->d[rINDEX2] / 10000) & 1) ? 10000 : 0;
8667 else
8668 ret=0;
8669
8670 18739404 break;
8671 }
8672
8673 case GAMEGUYCOUNTD:
8674 ret=game->guys[(currmap * MAPSCRSNORMAL) + (ri->d[rINDEX] / 10000)]*10000;
8675 break;
8676
8677 case CURMAP:
8678 22550639 ret=(1+currmap)*10000;
8679 22550639 break;
8680
8681 case CURSCR:
8682 14110188 ret=currscr*10000;
8683 14110188 break;
8684
8685 case ALLOCATEBITMAPR:
8686 125 ret=FFCore.do_allocate_bitmap();
8687 125 break;
8688
8689 case GETMIDI:
8690 63717 ret=(currmidi-(ZC_MIDI_COUNT-1))*10000;
8691 63717 break;
8692
8693 case CURDSCR:
8694 {
8695 5921469 int32_t di = (get_currscr()-DMaps[get_currdmap()].xoff);
8696
2/2
✓ Branch 0 taken 3037368 times.
✓ Branch 1 taken 2884101 times.
5921469 ret=(DMaps[get_currdmap()].type==dmOVERW ? currscr : di)*10000;
8697 }
8698 5921469 break;
8699
8700 case GAMEMAXMAPS:
8701 ret = (map_count)*10000;
8702 break;
8703 case GAMENUMMESSAGES:
8704 ret = (msg_count-1) * 10000;
8705 break;
8706
8707 case CURDMAP:
8708 49186486 ret=currdmap*10000;
8709 49186486 break;
8710
8711 case CURLEVEL:
8712 14019927 ret=DMaps[get_currdmap()].level*10000;
8713 14019927 break;
8714
8715 case GAMECLICKFREEZE:
8716 ret=disableClickToFreeze?0:10000;
8717 break;
8718
8719
8720 case NOACTIVESUBSC:
8721 ret=Hero.stopSubscreenFalling()?10000:0;
8722 break;///----------------------------------------------------------------------------------------------------//
8723 //BottleTypes
8724 case BOTTLECOUNTER:
8725 {
8726 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Counter[]"))
8727 {
8728 int32_t indx = ri->d[rINDEX]/10000;
8729 if(unsigned(indx) > 2)
8730 {
8731 Z_scripterrlog("Invalid index %d supplied to bottledata->Counter[].\n", indx);
8732 ret = -10000L;
8733 break;
8734 }
8735 ret = 10000L * ptr->counter[indx];
8736 }
8737 else ret = -10000L;
8738 }
8739 break;
8740
8741 case BOTTLEAMOUNT:
8742 {
8743 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Amount[]"))
8744 {
8745 int32_t indx = ri->d[rINDEX]/10000;
8746 if(unsigned(indx) > 2)
8747 {
8748 Z_scripterrlog("Invalid index %d supplied to bottledata->Amount[].\n", indx);
8749 ret = -10000L;
8750 break;
8751 }
8752 ret = 10000L * ptr->amount[indx];
8753 }
8754 else ret = -10000L;
8755 }
8756 break;
8757
8758 case BOTTLEPERCENT:
8759 {
8760 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "IsPercent[]"))
8761 {
8762 int32_t indx = ri->d[rINDEX]/10000;
8763 if(unsigned(indx) > 2)
8764 {
8765 Z_scripterrlog("Invalid index %d supplied to bottledata->IsPercent[].\n", indx);
8766 ret = -10000L;
8767 break;
8768 }
8769 ret = (ptr->flags & (1<<indx)) ? 10000L : 0;
8770 }
8771 else ret = -10000L;
8772 }
8773 break;
8774
8775 case BOTTLEFLAGS:
8776 {
8777 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Flags[]"))
8778 {
8779 int32_t indx = ri->d[rINDEX]/10000;
8780 if(unsigned(indx) > 3)
8781 {
8782 Z_scripterrlog("Invalid index %d supplied to bottledata->Flags[].\n", indx);
8783 ret = -10000L;
8784 break;
8785 }
8786 int32_t flag = 0;
8787 switch(indx)
8788 {
8789 case 0: flag = BTFLAG_AUTOONDEATH; break;
8790 case 1: flag = BTFLAG_ALLOWIFFULL; break;
8791 case 2: flag = BTFLAG_CURESWJINX; break;
8792 case 3: flag = BTFLAG_CUREITJINX; break;
8793 }
8794 ret = (ptr->flags & flag) ? 10000L : 0;
8795 }
8796 else ret = -10000L;
8797 }
8798 break;
8799
8800 case BOTTLENEXT:
8801 {
8802 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "NextType"))
8803 {
8804 ret = 10000L * ptr->next_type;
8805 }
8806 else ret = -10000L;
8807 }
8808 break;
8809 ///----------------------------------------------------------------------------------------------------//
8810 //BottleShops
8811 case BSHOPFILL:
8812 {
8813 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Fill[]"))
8814 {
8815 int32_t indx = ri->d[rINDEX]/10000;
8816 if(unsigned(indx) > 2)
8817 {
8818 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Fill[].\n", indx);
8819 ret = -10000L;
8820 break;
8821 }
8822 ret = 10000L * ptr->fill[indx];
8823 }
8824 else ret = -10000L;
8825 }
8826 break;
8827
8828 case BSHOPCOMBO:
8829 {
8830 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Combo[]"))
8831 {
8832 int32_t indx = ri->d[rINDEX]/10000;
8833 if(unsigned(indx) > 2)
8834 {
8835 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Combo[].\n", indx);
8836 ret = -10000L;
8837 break;
8838 }
8839 ret = 10000L * ptr->comb[indx];
8840 }
8841 else ret = -10000L;
8842 }
8843 break;
8844
8845 case BSHOPCSET:
8846 {
8847 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "CSet[]"))
8848 {
8849 int32_t indx = ri->d[rINDEX]/10000;
8850 if(unsigned(indx) > 2)
8851 {
8852 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->CSet[].\n", indx);
8853 ret = -10000L;
8854 break;
8855 }
8856 ret = 10000L * ptr->cset[indx];
8857 }
8858 else ret = -10000L;
8859 }
8860 break;
8861
8862 case BSHOPPRICE:
8863 {
8864 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Price[]"))
8865 {
8866 int32_t indx = ri->d[rINDEX]/10000;
8867 if(unsigned(indx) > 2)
8868 {
8869 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Price[].\n", indx);
8870 ret = -10000L;
8871 break;
8872 }
8873 ret = 10000L * ptr->price[indx];
8874 }
8875 else ret = -10000L;
8876 }
8877 break;
8878
8879 case BSHOPSTR:
8880 {
8881 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "InfoString[]"))
8882 {
8883 int32_t indx = ri->d[rINDEX]/10000;
8884 if(unsigned(indx) > 2)
8885 {
8886 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->InfoString[].\n", indx);
8887 ret = -10000L;
8888 break;
8889 }
8890 ret = 10000L * ptr->str[indx];
8891 }
8892 else ret = -10000L;
8893 }
8894 break;
8895
8896 ///----------------------------------------------------------------------------------------------------//
8897 //DMap Information
8898
8899 #define GET_DMAP_VAR(member, str) \
8900 { \
8901 int32_t ID = ri->d[rINDEX] / 10000; \
8902 if(BC::checkDMapID(ID, str) != SH::_NoError) \
8903 ret = -10000; \
8904 else \
8905 ret = DMaps[ID].member * 10000; \
8906 }
8907
8908 case DMAPFLAGSD:
8909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1764243 times.
1764243 GET_DMAP_VAR(flags, "Game->DMapFlags") break;
8910
8911 case DMAPLEVELD:
8912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1019 times.
1019 GET_DMAP_VAR(level, "Game->DMapLevel") break;
8913
8914 case DMAPCOMPASSD:
8915
1/2
✓ Branch 0 taken 255560 times.
✗ Branch 1 not taken.
255560 GET_DMAP_VAR(compass, "Game->DMapCompass") break;
8916
8917 case DMAPCONTINUED:
8918 GET_DMAP_VAR(cont, "Game->DMapContinue") break;
8919
8920 case DMAPLEVELPAL:
8921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 741668 times.
741668 GET_DMAP_VAR(color, "Game->DMapPalette") break;
8922
8923 case DMAPOFFSET:
8924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95414 times.
95414 GET_DMAP_VAR(xoff, "Game->DMapOffset") break;
8925
8926 case DMAPMAP:
8927 {
8928 9482 int32_t ID = ri->d[rINDEX] / 10000;
8929
8930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9482 times.
9482 if(BC::checkDMapID(ID, "Game->DMapMap") != SH::_NoError)
8931 ret = -10000;
8932 else
8933 9482 ret = (DMaps[ID].map+1) * 10000;
8934
8935 9482 break;
8936 }
8937
8938 case DMAPMIDID:
8939 {
8940 37 int32_t ID = ri->d[rINDEX] / 10000;
8941
8942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(BC::checkDMapID(ID, "Game->DMapMIDI") == SH::_NoError)
8943 {
8944 // Based on play_DmapMusic
8945
2/5
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
37 switch(DMaps[ID].midi)
8946 {
8947 case 2:
8948 ret = -60000;
8949 break; // Dungeon
8950
8951 case 3:
8952 ret = -30000;
8953 break; // Level 9
8954
8955 case 1:
8956 ret = -20000;
8957 break; // Overworld
8958
8959 case 0:
8960 4 ret = 0;
8961 4 break; // None
8962
8963 default:
8964 33 ret = (DMaps[ID].midi - 3) * 10000;
8965 33 }
8966 37 }
8967 else
8968 ret = -10000; // Which is valid, but whatever.
8969
8970 37 break;
8971 }
8972
8973 ///----------------------------------------------------------------------------------------------------//
8974 //Screen->ComboX
8975 #define GET_COMBO_VAR(member, str) \
8976 { \
8977 int32_t pos = ri->d[rINDEX] / 10000; \
8978 if(BC::checkComboPos(pos, str) != SH::_NoError) \
8979 { \
8980 ret = -10000; \
8981 } \
8982 else \
8983 ret = tmpscr->member[pos]*10000; \
8984 }
8985
8986 case COMBODD:
8987
1/2
✓ Branch 0 taken 27341446 times.
✗ Branch 1 not taken.
27341446 GET_COMBO_VAR(data, "Screen->ComboD[]") break;
8988
8989 case COMBOCD:
8990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2709583 times.
2709583 GET_COMBO_VAR(cset, "Screen->ComboC[]") break;
8991
8992 case COMBOFD:
8993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3906326 times.
3906326 GET_COMBO_VAR(sflag, "Screen->ComboF[]") break;
8994
8995 #define GET_COMBO_VAR_BUF(member, str) \
8996 { \
8997 int32_t pos = ri->d[rINDEX] / 10000; \
8998 if(BC::checkComboPos(pos, str) != SH::_NoError) \
8999 { \
9000 ret = -10000; \
9001 } \
9002 else \
9003 ret = combobuf[tmpscr->data[pos]].member * 10000; \
9004 }
9005
9006 case COMBOTD:
9007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26494389 times.
26494389 GET_COMBO_VAR_BUF(type, "Screen->ComboT[]") break;
9008
9009 case COMBOID:
9010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2975118 times.
2975118 GET_COMBO_VAR_BUF(flag, "Screen->ComboI[]") break;
9011
9012 case COMBOSD:
9013 {
9014 96784 int32_t pos = ri->d[rINDEX] / 10000;
9015
9016
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 95200 times.
96784 if(BC::checkComboPos(pos, "Screen->ComboS[]") != SH::_NoError)
9017 1584 ret = -10000;
9018 else
9019 95200 ret = (combobuf[tmpscr->data[pos]].walk & 0xF) * 10000;
9020 }
9021 96784 break;
9022
9023 case COMBOED:
9024 {
9025 int32_t pos = ri->d[rINDEX] / 10000;
9026
9027 if(BC::checkComboPos(pos, "Screen->ComboE[]") != SH::_NoError)
9028 ret = -10000;
9029 else
9030 ret = ((combobuf[tmpscr->data[pos]].walk & 0xF0)>>4) * 10000;
9031 }
9032 break;
9033
9034 ///----------------------------------------------------------------------------------------------------//
9035 //Game->GetComboX
9036
9037 case COMBODDM:
9038 {
9039 13758809 int32_t pos = (ri->d[rINDEX])/10000;
9040 13758809 int32_t sc = (ri->d[rEXP1]/10000);
9041 13758809 int32_t m = (ri->d[rINDEX2]/10000)-1;
9042
2/2
✓ Branch 0 taken 11885286 times.
✓ Branch 1 taken 1873523 times.
13758809 int32_t scr = zc_max(m*MAPSCRS+sc,0);
9043 13758809 int32_t layr = whichlayer(scr);
9044
9045
2/4
✓ Branch 0 taken 13758809 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13758809 times.
13758809 if(pos < 0 || pos >= 176)
9046 {
9047 Z_scripterrlog("Invalid combo position (%d) passed to GetComboData", pos);
9048 ret = -10000;
9049 }
9050
1/2
✓ Branch 0 taken 13758809 times.
✗ Branch 1 not taken.
13758809 else if(scr < 0)
9051 {
9052 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboData", scr);
9053 ret = -10000;
9054 }
9055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13758809 times.
13758809 else if(sc >= MAPSCRS)
9056 {
9057 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboData", sc);
9058 ret = -10000;
9059 }
9060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13758809 times.
13758809 else if(m >= map_count)
9061 {
9062 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboData", m);
9063 ret = -10000;
9064 }
9065
2/2
✓ Branch 0 taken 11885286 times.
✓ Branch 1 taken 1873523 times.
13758809 else if(m < 0) ret = 0; //No layer present
9066
9067 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
9068 else
9069 {
9070
2/2
✓ Branch 0 taken 109146 times.
✓ Branch 1 taken 11776140 times.
11885286 if(scr==(currmap*MAPSCRS+currscr))
9071 109146 ret=tmpscr->data[pos]*10000;
9072
2/2
✓ Branch 0 taken 5826733 times.
✓ Branch 1 taken 5949407 times.
11776140 else if(layr>-1)
9073 5826733 ret=tmpscr2[layr].data[pos]*10000;
9074 5949407 else ret=TheMaps[scr].data[pos]*10000;
9075 }
9076
9077 }
9078 13758809 break;
9079
9080 case COMBOCDM:
9081 {
9082 2272124 int32_t pos = (ri->d[rINDEX])/10000;
9083 2272124 int32_t sc = (ri->d[rEXP1]/10000);
9084 2272124 int32_t m = (ri->d[rINDEX2]/10000)-1;
9085
1/2
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
2272124 int32_t scr = zc_max(m*MAPSCRS+sc,0);
9086 2272124 int32_t layr = whichlayer(scr);
9087
9088
2/4
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2272124 times.
2272124 if(pos < 0 || pos >= 176)
9089 {
9090 Z_scripterrlog("Invalid combo position (%d) passed to GetComboCSet", pos);
9091 ret = -10000;
9092 }
9093
1/2
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
2272124 else if(scr < 0)
9094 {
9095 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboCSet", scr);
9096 ret = -10000;
9097 }
9098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 else if(sc >= MAPSCRS)
9099 {
9100 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboCSet", sc);
9101 ret = -10000;
9102 }
9103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 else if(m >= map_count)
9104 {
9105 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboCSet", m);
9106 ret = -10000;
9107 }
9108
1/2
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
2272124 else if(m < 0) ret = 0; //No layer present
9109
9110 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
9111 else
9112 {
9113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 if(scr==(currmap*MAPSCRS+currscr))
9114 ret=tmpscr->cset[pos]*10000;
9115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 else if(layr>-1)
9116 ret=tmpscr2[layr].cset[pos]*10000;
9117 2272124 else ret=TheMaps[scr].cset[pos]*10000;
9118 }
9119
9120 }
9121 2272124 break;
9122
9123 case COMBOFDM:
9124 {
9125 5866709 int32_t pos = (ri->d[rINDEX])/10000;
9126 5866709 int32_t sc = (ri->d[rEXP1]/10000);
9127 5866709 int32_t m = (ri->d[rINDEX2]/10000)-1;
9128
1/2
✓ Branch 0 taken 5866709 times.
✗ Branch 1 not taken.
5866709 int32_t scr = zc_max(m*MAPSCRS+sc,0);
9129 5866709 int32_t layr = whichlayer(scr);
9130
9131
3/4
✓ Branch 0 taken 5866709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4000 times.
✓ Branch 3 taken 5862709 times.
5866709 if(pos < 0 || pos >= 176)
9132 {
9133 4000 Z_scripterrlog("Invalid combo position (%d) passed to GetComboFlag", pos);
9134 4000 ret = -10000;
9135 4000 }
9136
1/2
✓ Branch 0 taken 5862709 times.
✗ Branch 1 not taken.
5862709 else if(scr < 0)
9137 {
9138 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboFlag", scr);
9139 ret = -10000;
9140 }
9141
2/2
✓ Branch 0 taken 4212 times.
✓ Branch 1 taken 5858497 times.
5862709 else if(sc >= MAPSCRS)
9142 {
9143 4212 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboFlag", sc);
9144 4212 ret = -10000;
9145 4212 }
9146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5858497 times.
5858497 else if(m >= map_count)
9147 {
9148 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboFlag", m);
9149 ret = -10000;
9150 }
9151
1/2
✓ Branch 0 taken 5858497 times.
✗ Branch 1 not taken.
5858497 else if(m < 0) ret = 0; //No layer present
9152 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
9153 else
9154 {
9155
2/2
✓ Branch 0 taken 317735 times.
✓ Branch 1 taken 5540762 times.
5858497 if(scr==(currmap*MAPSCRS+currscr))
9156 317735 ret=tmpscr->sflag[pos]*10000;
9157
2/2
✓ Branch 0 taken 4629060 times.
✓ Branch 1 taken 911702 times.
5540762 else if(layr>-1)
9158 4629060 ret=tmpscr2[layr].sflag[pos]*10000;
9159 911702 else ret=TheMaps[scr].sflag[pos]*10000;
9160 }
9161
9162 }
9163 5866709 break;
9164
9165 case COMBOTDM:
9166 {
9167 449777 int32_t pos = (ri->d[rINDEX])/10000;
9168 449777 int32_t sc = (ri->d[rEXP1]/10000);
9169 449777 int32_t m = (ri->d[rINDEX2]/10000)-1;
9170
1/2
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
449777 int32_t scr = zc_max(m*MAPSCRS+sc,0);
9171 449777 int32_t layr = whichlayer(scr);
9172
9173
2/4
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 449777 times.
449777 if(pos < 0 || pos >= 176)
9174 {
9175 Z_scripterrlog("Invalid combo position (%d) passed to GetComboType", pos);
9176 ret = -10000;
9177 }
9178
1/2
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
449777 else if(scr < 0)
9179 {
9180 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboType", scr);
9181 ret = -10000;
9182 }
9183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 449777 times.
449777 else if(sc >= MAPSCRS)
9184 {
9185 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboType", sc);
9186 ret = -10000;
9187 }
9188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 449777 times.
449777 else if(m >= map_count)
9189 {
9190 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboType", m);
9191 ret = -10000;
9192 }
9193
1/2
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
449777 else if(m < 0) ret = 0; //No layer present
9194
9195 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
9196 else
9197 {
9198
2/2
✓ Branch 0 taken 106581 times.
✓ Branch 1 taken 343196 times.
449777 if(scr==(currmap*MAPSCRS+currscr))
9199 106581 ret=combobuf[tmpscr->data[pos]].type*10000;
9200
2/2
✓ Branch 0 taken 105393 times.
✓ Branch 1 taken 237803 times.
343196 else if(layr>-1)
9201 105393 ret=combobuf[tmpscr2[layr].data[pos]].type*10000;
9202 713409 else ret=combobuf[
9203 713409 TheMaps[scr].data[pos]].type*10000;
9204 }
9205 }
9206 449777 break;
9207
9208 case COMBOIDM:
9209 {
9210 421915 int32_t pos = (ri->d[rINDEX])/10000;
9211 421915 int32_t sc = (ri->d[rEXP1]/10000);
9212 421915 int32_t m = (ri->d[rINDEX2]/10000)-1;
9213
1/2
✓ Branch 0 taken 421915 times.
✗ Branch 1 not taken.
421915 int32_t scr = zc_max(m*MAPSCRS+sc,0);
9214 421915 int32_t layr = whichlayer(scr);
9215
9216
3/4
✓ Branch 0 taken 421915 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4000 times.
✓ Branch 3 taken 417915 times.
421915 if(pos < 0 || pos >= 176)
9217 {
9218 4000 Z_scripterrlog("Invalid combo position (%d) passed to GetComboInherentFlag", pos);
9219 4000 ret = -10000;
9220 4000 }
9221
1/2
✓ Branch 0 taken 417915 times.
✗ Branch 1 not taken.
417915 else if(scr < 0)
9222 {
9223 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", scr);
9224 ret = -10000;
9225 }
9226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417915 times.
417915 else if(sc >= MAPSCRS)
9227 {
9228 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", sc);
9229 ret = -10000;
9230 }
9231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417915 times.
417915 else if(m >= map_count)
9232 {
9233 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboInherentFlag", m);
9234 ret = -10000;
9235 }
9236
1/2
✓ Branch 0 taken 417915 times.
✗ Branch 1 not taken.
417915 else if(m < 0) ret = 0; //No layer present
9237
9238 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
9239 else
9240 {
9241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417915 times.
417915 if(scr==(currmap*MAPSCRS+currscr))
9242 ret=combobuf[tmpscr->data[pos]].flag*10000;
9243
1/2
✓ Branch 0 taken 417915 times.
✗ Branch 1 not taken.
417915 else if(layr>-1)
9244 417915 ret=combobuf[tmpscr2[layr].data[pos]].flag*10000;
9245 else ret=combobuf[TheMaps[scr].data[pos]].flag*10000;
9246 }
9247 }
9248 421915 break;
9249
9250 case COMBOSDM:
9251 {
9252 6342577 int32_t pos = (ri->d[rINDEX])/10000;
9253 6342577 int32_t sc = (ri->d[rEXP1]/10000);
9254 6342577 int32_t m = (ri->d[rINDEX2]/10000)-1;
9255
2/2
✓ Branch 0 taken 6341872 times.
✓ Branch 1 taken 705 times.
6342577 int32_t scr = zc_max(m*MAPSCRS+sc,0);
9256 6342577 int32_t layr = whichlayer(scr);
9257
9258
2/4
✓ Branch 0 taken 6342577 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6342577 times.
6342577 if(pos < 0 || pos >= 176)
9259 {
9260 Z_scripterrlog("Invalid combo position (%d) passed to GetComboSolid", pos);
9261 ret = -10000;
9262 }
9263
1/2
✓ Branch 0 taken 6342577 times.
✗ Branch 1 not taken.
6342577 else if(scr < 0)
9264 {
9265 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboSolid", scr);
9266 ret = -10000;
9267 }
9268
2/2
✓ Branch 0 taken 2106 times.
✓ Branch 1 taken 6340471 times.
6342577 else if(sc >= MAPSCRS)
9269 {
9270 2106 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboSolid", sc);
9271 2106 ret = -10000;
9272 2106 }
9273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6340471 times.
6340471 else if(m >= map_count)
9274 {
9275 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboSolid", m);
9276 ret = -10000;
9277 }
9278
2/2
✓ Branch 0 taken 6339767 times.
✓ Branch 1 taken 704 times.
6340471 else if(m < 0) ret = 0; //No layer present
9279
9280 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
9281 else
9282 {
9283
2/2
✓ Branch 0 taken 581032 times.
✓ Branch 1 taken 5758735 times.
6339767 if(scr==(currmap*MAPSCRS+currscr))
9284 581032 ret=(combobuf[tmpscr->data[pos]].walk&15)*10000;
9285
2/2
✓ Branch 0 taken 644433 times.
✓ Branch 1 taken 5114302 times.
5758735 else if(layr>-1)
9286 644433 ret=(combobuf[tmpscr2[layr].data[pos]].walk&15)*10000;
9287 5114302 else ret=(combobuf[TheMaps[scr].data[pos]].walk&15)*10000;
9288 }
9289
9290 }
9291 6342577 break;
9292
9293
9294
9295
9296 ///----------------------------------------------------------------------------------------------------//
9297 //Screen Information
9298
9299 #define GET_SCREENDATA_VAR_INT32(member, str) \
9300 { \
9301 ret = (tmpscr->member *10000); \
9302 } \
9303
9304 #define GET_SCREENDATA_VAR_INT16(member, str) \
9305 { \
9306 ret = (tmpscr->member *10000); \
9307 } \
9308
9309 #define GET_SCREENDATA_VAR_BYTE(member, str) \
9310 { \
9311 ret = (tmpscr->member *10000); \
9312 } \
9313
9314 #define GET_SCREENDATA_VAR_INDEX32(member, str, indexbound) \
9315 { \
9316 int32_t indx = ri->d[rINDEX] / 10000; \
9317 ret = (tmpscr->member[indx] *10000); \
9318 } \
9319
9320 #define GET_SCREENDATA_VAR_INDEX16(member, str, indexbound) \
9321 { \
9322 int32_t indx = ri->d[rINDEX] / 10000; \
9323 ret = (tmpscr->member[indx] *10000); \
9324 } \
9325
9326 #define GET_SCREENDATA_BYTE_INDEX(member, str, indexbound) \
9327 { \
9328 int32_t indx = ri->d[rINDEX] / 10000; \
9329 ret = (tmpscr->member[indx] *10000); \
9330 } \
9331
9332 //byte
9333 #define GET_SCREENDATA_LAYER_INDEX(member, str, indexbound) \
9334 { \
9335 int32_t indx = ri->d[rINDEX] / 10000; \
9336 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
9337 if(indx < 1 || indx > indexbound ) \
9338 { \
9339 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", str, indx); \
9340 ret = -10000; \
9341 } \
9342 else \
9343 { \
9344 ret = (tmpscr->member[indx-1] *10000); \
9345 } \
9346 } \
9347
9348
9349 #define GET_SCREENDATA_BOOL_INDEX(member, str, indexbound) \
9350 { \
9351 int32_t indx = ri->d[rINDEX] / 10000; \
9352 if(indx < 0 || indx > indexbound ) \
9353 { \
9354 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
9355 ret = -10000; \
9356 } \
9357 else \
9358 { \
9359 ret = (tmpscr->member[indx]?10000:0); \
9360 } \
9361 } \
9362
9363 #define GET_FFC_BOOL_INDEX(member, str, indexbound) \
9364 { \
9365 int32_t indx = ri->d[rINDEX] / 10000; \
9366 if(indx < 0 || indx > indexbound ) \
9367 { \
9368 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
9369 ret = -10000; \
9370 } \
9371 else \
9372 { \
9373 ret = (tmpscr->ffcs[indx].member?10000:0); \
9374 } \
9375 } \
9376
9377
9378 #define GET_SCREENDATA_FLAG(member, str, indexbound) \
9379 { \
9380 int32_t flag = (value/10000); \
9381 ret = (tmpscr->member&flag) ? 10000 : 0); \
9382 } \
9383
9384 case SCREENDATAVALID: GET_SCREENDATA_VAR_BYTE(valid, "Valid"); break; //b
9385 case SCREENDATAGUY: GET_SCREENDATA_VAR_BYTE(guy, "Guy"); break; //b
9386 case SCREENDATASTRING: GET_SCREENDATA_VAR_INT32(str, "String"); break; //w
9387 case SCREENDATAROOM: GET_SCREENDATA_VAR_BYTE(room, "RoomType"); break; //b
9388 case SCREENDATAITEM:
9389 {
9390 if(tmpscr->hasitem)
9391 ret = (tmpscr->item *10000);
9392 else ret = -10000;
9393 break;
9394 }
9395 case SCREENDATAHASITEM: GET_SCREENDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
9396 case SCREENDATATILEWARPTYPE: GET_SCREENDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
9397 //case SCREENDATATILEWARPOVFLAGS: GET_SCREENDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
9398 case SCREENDATADOORCOMBOSET: GET_SCREENDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
9399 case SCREENDATAWARPRETX: GET_SCREENDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
9400 case SCREENDATAWARPRETY: GET_SCREENDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
9401 case SCREENDATAWARPRETURNC: GET_SCREENDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
9402 case SCREENDATASTAIRX: GET_SCREENDATA_VAR_BYTE(stairx, "StairsX"); break; //b
9403 case SCREENDATASTAIRY: GET_SCREENDATA_VAR_BYTE(stairy, "StairsY"); break; //b
9404 case SCREENDATAITEMX: GET_SCREENDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
9405 case SCREENDATAITEMY: GET_SCREENDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
9406 case SCREENDATACOLOUR: GET_SCREENDATA_VAR_INT32(color, "CSet"); break; //w
9407 case SCREENDATAENEMYFLAGS: GET_SCREENDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
9408 case SCREENDATADOOR: GET_SCREENDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
9409 case SCREENDATATILEWARPDMAP: GET_SCREENDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
9410 case SCREENDATATILEWARPSCREEN: GET_SCREENDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
9411 case SCREENDATAEXITDIR: GET_SCREENDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
9412 case SCREENDATAENEMY: GET_SCREENDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
9413 case SCREENDATAPATTERN: GET_SCREENDATA_VAR_BYTE(pattern, "Pattern"); break; //b
9414 case SCREENDATASIDEWARPTYPE: GET_SCREENDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
9415 //case SCREENDATASIDEWARPOVFLAGS: GET_SCREENDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
9416 case SCREENDATAWARPARRIVALX: GET_SCREENDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
9417 case SCREENDATAWARPARRIVALY: GET_SCREENDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
9418 case SCREENDATAPATH: GET_SCREENDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
9419 case SCREENDATASIDEWARPSC: GET_SCREENDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
9420 case SCREENDATASIDEWARPDMAP: GET_SCREENDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
9421 case SCREENDATASIDEWARPINDEX: GET_SCREENDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
9422 case SCREENDATAUNDERCOMBO: GET_SCREENDATA_VAR_INT32(undercombo, "Undercombo"); break; //w
9423 case SCREENDATAUNDERCSET: GET_SCREENDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
9424 case SCREENDATACATCHALL: GET_SCREENDATA_VAR_INT32(catchall, "Catchall"); break; //W
9425
9426 case SCREENDATACSENSITIVE: GET_SCREENDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
9427 case SCREENDATANORESET: GET_SCREENDATA_VAR_INT32(noreset, "NoReset"); break; //W
9428 case SCREENDATANOCARRY: GET_SCREENDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
9429 case SCREENDATALAYERMAP: GET_SCREENDATA_LAYER_INDEX(layermap, "LayerMap", 6); break; //B, 6 OF THESE
9430 case SCREENDATALAYERSCREEN: GET_SCREENDATA_LAYER_INDEX(layerscreen, "LayerScreen", 6); break; //B, 6 OF THESE
9431 case SCREENDATALAYEROPACITY: GET_SCREENDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 6); break; //B, 6 OF THESE
9432 case SCREENDATALAYERINVIS:
9433 {
9434 int32_t indx = ri->d[rINDEX] / 10000;
9435 if(indx < 0 || indx > 6 )
9436 {
9437 Z_scripterrlog("Invalid Index passed to Screen->LayerInvisible[]: %d\n", indx);
9438 ret = 0;
9439 }
9440 else
9441 {
9442 ret = ((tmpscr->hidelayers >> indx) & 1) *10000;
9443 }
9444 break;
9445 }
9446 case SCREENDATASCRIPTDRAWS:
9447 {
9448 int32_t indx = ri->d[rINDEX] / 10000;
9449 if(indx < 0 || indx > 7 )
9450 {
9451 Z_scripterrlog("Invalid Index passed to Screen->HideScriptLayer[]: %d\n", indx);
9452 ret = 0;
9453 }
9454 else
9455 {
9456 ret = ((tmpscr->hidescriptlayers >> indx) & 1) ? 0 : 10000;
9457 }
9458 break;
9459 }
9460 case SCREENDATATIMEDWARPTICS: GET_SCREENDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
9461 case SCREENDATANEXTMAP: GET_SCREENDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
9462 case SCREENDATANEXTSCREEN: GET_SCREENDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
9463 109824 case SCREENDATASECRETCOMBO: GET_SCREENDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
9464 case SCREENDATASECRETCSET: GET_SCREENDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
9465 case SCREENDATASECRETFLAG: GET_SCREENDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
9466 case SCREENDATAVIEWX: break;//GET_SCREENDATA_VAR_INT32(viewX, "ViewX"); break; //W
9467 case SCREENDATAVIEWY: break;//GET_SCREENDATA_VAR_INT32(viewY, "ViewY"); break; //W
9468 case SCREENDATASCREENWIDTH: break;//GET_SCREENDATA_VAR_BYTE(scrWidth, "Width"); break; //B
9469 case SCREENDATASCREENHEIGHT: break;//GET_SCREENDATA_VAR_BYTE(scrHeight, "Height"); break; //B
9470 case SCREENDATAENTRYX: GET_SCREENDATA_VAR_BYTE(entry_x, "EntryX"); break; //B
9471 case SCREENDATAENTRYY: GET_SCREENDATA_VAR_BYTE(entry_y, "EntryY"); break; //B
9472 //Number of ffcs that are in use (have valid data
9473 case SCREENDATANUMFF:
9474 {
9475 uint32_t indx = ri->d[rINDEX] / 10000;
9476 if (!indx || indx > MAXFFCS)
9477 {
9478 Z_scripterrlog("Invalid Index passed to Screen->NumFFCs[%d].\n Valid indices are 1 through %d.\n", indx, MAXFFCS);
9479 ret = 0;
9480 }
9481 else
9482 {
9483 --indx;
9484 ret = (tmpscr->ffcs[indx].data != 0) ? 10000 : 0;
9485 }
9486 break;
9487 }
9488 //inita //INT32, 32 OF THESE, EACH WITH 2
9489 case SCREENDATAFFINITIALISED: {
9490 int32_t indx = ri->d[rINDEX] / 10000;
9491 if (indx < 0 || indx > MAXFFCS-1)
9492 {
9493 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", indx, "FFCRunning");
9494 ret = -10000;
9495 }
9496 else
9497 {
9498 ret = get_script_engine_data(ScriptType::FFC, indx).initialized ? 10000 : 0;
9499 }
9500 }
9501 break;
9502
9503 case SCREENDATASCRIPTENTRY: GET_SCREENDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
9504 case SCREENDATASCRIPTOCCUPANCY: GET_SCREENDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
9505 case SCREENDATASCRIPTEXIT: GET_SCREENDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
9506 case SCREENDATAOCEANSFX: GET_SCREENDATA_VAR_BYTE(oceansfx, "OceanSFX"); break; //B
9507 case SCREENDATABOSSSFX: GET_SCREENDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
9508 1 case SCREENDATASECRETSFX: GET_SCREENDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
9509 case SCREENDATAHOLDUPSFX: GET_SCREENDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
9510 case SCREENDATASCREENMIDI:
9511 {
9512 ret = ((tmpscr->screen_midi+(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT)) *10000);
9513 break;
9514 }
9515 case SCREENDATALENSLAYER: GET_SCREENDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
9516
9517 case SCREENSIDEWARPID:
9518 {
9519 int32_t indx = ri->d[rINDEX] / 10000;
9520
9521 ret = (((tmpscr->flags2 >> indx) & 1)
9522 ? (tmpscr->sidewarpindex >> (2*indx)) & 3 //Return which warp is set
9523 : -1 //Returns -1 if no warp is set
9524 )*10000;
9525 break;
9526 }
9527
9528 case SCREENDATATILEWARPOVFLAGS:
9529 {
9530 int32_t indx = ri->d[rINDEX] / 10000;
9531 if ( ((unsigned)indx) > 3 )
9532 {
9533 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
9534 ret = 0;
9535 }
9536 else
9537 {
9538 ret = (tmpscr->tilewarpoverlayflags & (1<<indx))?10000:0;
9539 }
9540 break;
9541 }
9542
9543 case SCREENDATASIDEWARPOVFLAGS:
9544 {
9545 int32_t indx = ri->d[rINDEX] / 10000;
9546 if ( ((unsigned)indx) > 3 )
9547 {
9548 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
9549 ret = 0;
9550 }
9551 else
9552 {
9553 ret = (tmpscr->sidewarpoverlayflags & (1<<indx))?10000:0;
9554 }
9555 break;
9556 }
9557
9558 case SCREENDATATWARPRETSQR:
9559 {
9560 int32_t indx = ri->d[rINDEX] / 10000;
9561 if ( ((unsigned)indx) > 3)
9562 {
9563 ret = -10000;
9564 Z_scripterrlog("Invalid Array Index passed to Screen->TileWarpReturnSquare[]: %d\n", indx);
9565
9566 }
9567 else
9568 {
9569 ret = ((tmpscr->warpreturnc>>(indx*2))&3) * 10000;
9570 }
9571 break;
9572 }
9573
9574
9575 case SCREENDATASWARPRETSQR:
9576 {
9577 int32_t indx = ri->d[rINDEX] / 10000;
9578 if ( ((unsigned)indx) > 3)
9579 {
9580 ret = -10000;
9581 Z_scripterrlog("Invalid Array Index passed to Screen->SideWarpReturnSquare[]: %d\n", indx);
9582
9583 }
9584 else
9585 {
9586 ret = ((tmpscr->warpreturnc>>(8+(indx*2)))&3) * 10000;
9587 }
9588 break;
9589 }
9590
9591 case SCREENDATAFLAGS:
9592 {
9593 int32_t flagid = (ri->d[rINDEX])/10000;
9594 //bool valtrue = ( value ? 10000 : 0);
9595 switch(flagid)
9596 {
9597 case 0: ret = (tmpscr->flags * 10000); break;
9598 case 1: ret = (tmpscr->flags2 * 10000); break;
9599 case 2: ret = (tmpscr->flags3 * 10000); break;
9600 case 3: ret = (tmpscr->flags4 * 10000); break;
9601 case 4: ret = (tmpscr->flags5 * 10000); break;
9602 case 5: ret = (tmpscr->flags6 * 10000); break;
9603 case 6: ret = (tmpscr->flags7 * 10000); break;
9604 case 7: ret = (tmpscr->flags8 * 10000); break;
9605 case 8: ret = (tmpscr->flags9 * 10000); break;
9606 case 9: ret = (tmpscr->flags10 * 10000); break;
9607 default:
9608 {
9609 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
9610 ret = -10000;
9611 break;
9612
9613 }
9614 }
9615 break;
9616 //GET_SCREENDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
9617 }
9618
9619 case SCREENSECRETSTRIGGERED:
9620 {
9621 910 ret = triggered_screen_secrets ? 10000L : 0L;
9622 910 break;
9623 }
9624
9625 case SCREENDATAGUYCOUNT:
9626 {
9627 int mi = get_mi();
9628 if(mi < 0)
9629 ret = -10000;
9630 else ret = game->guys[mi] * 10000;
9631 break;
9632 }
9633
9634 case SHOWNMSG:
9635 {
9636 ret = ((msg_active || msg_onscreen) ? msgstr : 0) * 10000L;
9637 break;
9638 }
9639
9640 case SDD:
9641 {
9642
2/2
✓ Branch 0 taken 387442 times.
✓ Branch 1 taken 2580 times.
390022 int32_t di = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
9643 390022 ret=FFScript::get_screen_d(di, ri->d[rINDEX]/10000);
9644 }
9645 390022 break;
9646
9647 case SDDD:
9648 43250 ret=FFScript::get_screen_d((ri->d[rINDEX])/10000 + ((get_currdmap())<<7), ri->d[rINDEX2] / 10000);
9649 43250 break;
9650
9651 case LINKOTILE:
9652 ret=FFCore.getHeroOTile(ri->d[rINDEX]/10000, ri->d[rINDEX2] / 10000);
9653 break;
9654
9655 case SDDDD:
9656 3 ret=FFScript::get_screen_d(ri->d[rINDEX2] / 10000 + ((ri->d[rINDEX]/10000)<<7), ri->d[rEXP1] / 10000);
9657 3 break;
9658
9659 case SCRDOORD:
9660 4 ret=tmpscr->door[ri->d[rINDEX]/10000]*10000;
9661 4 break;
9662
9663 case SCREENSCRIPT:
9664 ret=tmpscr->script*10000;
9665 break;
9666
9667 case SCREENINITD:
9668 ret = tmpscr->screeninitd[ri->d[rINDEX]/10000];
9669 break;
9670
9671 case MAPDATAINITDARRAY:
9672 {
9673 if ( ri->mapsref == MAX_SIGNED_32 )
9674 {
9675 Z_scripterrlog("Script attempted to use a mapdata->InitD[%d] on a pointer that is uninitialised\n",ri->d[rINDEX]/10000);
9676 break;
9677 }
9678 else
9679 {
9680 mapscr *m = GetMapscr(ri->mapsref);
9681 ret = m->screeninitd[ri->d[rINDEX]/10000];
9682 }
9683 break;
9684 }
9685
9686 case MAPDATALAYERINVIS:
9687 {
9688 int32_t indx = ri->d[rINDEX] / 10000;
9689 if(indx < 0 || indx > 6 )
9690 {
9691 Z_scripterrlog("Invalid Index passed to mapdata->LayerInvisible[]: %d\n", indx);
9692 ret = 0;
9693 }
9694 else
9695 {
9696 if ( ri->mapsref == MAX_SIGNED_32 )
9697 {
9698 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","LayerInvisible");
9699 ret = -10000;
9700 }
9701 else
9702 {
9703 mapscr *m = GetMapscr(ri->mapsref);
9704 ret = ((m->hidelayers >> indx) & 1) *10000;
9705 }
9706 }
9707 break;
9708 }
9709 case MAPDATASCRIPTDRAWS:
9710 {
9711 int32_t indx = ri->d[rINDEX] / 10000;
9712 if(indx < 0 || indx > 7 )
9713 {
9714 Z_scripterrlog("Invalid Index passed to mapdata->DisableScriptDraws[]: %d\n", indx);
9715 ret = 0;
9716 }
9717 else
9718 {
9719 if ( ri->mapsref == MAX_SIGNED_32 )
9720 {
9721 Z_scripterrlog("Script attempted to use a mapdata->DisableScriptDraws on a pointer that is uninitialised\n");
9722 ret = -10000;
9723 }
9724 else
9725 {
9726 mapscr *m = GetMapscr(ri->mapsref);
9727 ret = ((m->hidescriptlayers >> indx) & 1) ? 0 : 10000;
9728 }
9729 }
9730 break;
9731 }
9732
9733 //These use the same method as GetScreenD -Z
9734 case SCREENWIDTH:
9735 // ret=FFScript::get_screenWidth(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9736 break;
9737
9738 case SCREENHEIGHT:
9739 // ret=FFScript::get_screenHeight(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9740 break;
9741
9742 case SCREENVIEWX:
9743 // ret=get_screenViewX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9744 break;
9745
9746 case SCREENVIEWY:
9747 // ret=get_screenViewY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9748 break;
9749
9750 case SCREENGUY:
9751 ret=get_screenGuy(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9752 break;
9753
9754 case SCREENSTRING:
9755 ret=get_screenString(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9756 break;
9757
9758 case SCREENROOM:
9759 ret=get_screenRoomtype(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9760 break;
9761
9762 case SCREENENTX:
9763 ret=get_screenEntryX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9764 break;
9765
9766 case SCREENENTY:
9767 ret=get_screenEntryY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9768 break;
9769
9770 case SCREENITEM:
9771 ret=get_screenitem(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9772 break;
9773
9774 case SCREENUNDCMB:
9775 ret=get_screenundercombo(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9776 break;
9777
9778 case SCREENUNDCST:
9779 ret=get_screenundercset(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9780 break;
9781
9782 case SCREENCATCH:
9783 ret=get_screenatchall(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9784 break;
9785
9786
9787 case LIT:
9788 10246 ret= darkroom ? 0 : 10000;
9789 10246 break;
9790
9791 case WAVY:
9792 7214 ret = wavy*10000;
9793 7214 break;
9794
9795 case QUAKE:
9796 2272 ret = quakeclk*10000;
9797 2272 break;
9798
9799 case SCREENFLAGSD:
9800 6641017 ret = get_screenflags(tmpscr,vbound(ri->d[rINDEX] / 10000,0,9));
9801 6641017 break;
9802
9803 case SCREENEFLAGSD:
9804 1524086 ret = get_screeneflags(tmpscr,vbound(ri->d[rINDEX] / 10000,0,2));
9805 1524086 break;
9806
9807 case NPCCOUNT:
9808 11320291 ret = guys.Count()*10000;
9809 11320291 break;
9810
9811 case ROOMDATA:
9812 ret = tmpscr->catchall*10000;
9813 break;
9814
9815 case ROOMTYPE:
9816 ret = tmpscr->room*10000;
9817 break;
9818
9819 case PUSHBLOCKX:
9820
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 229459 times.
229611 ret = mblock2.active() ? int32_t(mblock2.x)*10000 : -10000;
9821 229611 break;
9822
9823 case PUSHBLOCKY:
9824
1/2
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
91 ret = mblock2.active() ? int32_t(mblock2.y)*10000 : -10000;
9825 91 break;
9826
9827 case PUSHBLOCKLAYER:
9828 ret = mblock2.active() ? int32_t(mblock2.blockLayer)*10000 : -10000;
9829 break;
9830
9831 case PUSHBLOCKCOMBO:
9832 ret = mblock2.bcombo*10000;
9833 break;
9834
9835 case PUSHBLOCKCSET:
9836 ret = mblock2.cs*10000;
9837 break;
9838
9839 case UNDERCOMBO:
9840 1 ret = tmpscr->undercombo*10000;
9841 1 break;
9842
9843 case UNDERCSET:
9844 1 ret = tmpscr->undercset*10000;
9845 1 break;
9846
9847 //Creates an lweapon using an iemdata struct values to generate its properties.
9848 //Useful in conjunction with the new weapon editor.
9849 case CREATELWPNDX:
9850 {
9851 //Z_message("Trying to get Player->SetExtend().\n");
9852 int32_t ID = (ri->d[rINDEX] / 10000);
9853 int32_t itemid = (ri->d[rINDEX2]/10000);
9854 itemid = vbound(itemid,0,(MAXITEMS-1));
9855
9856 //Z_scripterrlog("GetHeroExtend rid->[2] is (%i), trying to use for '%s'\n", ri->d[rEXP1], "ri->d[rEXP1]");
9857 //Z_scripterrlog("GetHeroExtend rid->[1] is (%i), trying to use for '%s'\n", state, "state");
9858 //Z_scripterrlog("GetHeroExtend rid->[0] is (%i), trying to use for '%s'\n", dir, "dir");
9859 if ( Lwpns.Count() < 256 )
9860 {
9861
9862 Lwpns.add
9863 (
9864 new weapon
9865 (
9866 (zfix)0, /*X*/
9867 (zfix)0, /*Y*/
9868 (zfix)0, /*Z*/
9869 ID, /*id*/
9870 0, /*type*/
9871 0, /*power*/
9872 0, /*dir*/
9873 -1, /*Parentid*/
9874 Hero.getUID(), /*prntid*/
9875 false, /*isdummy*/
9876 1, /*script_gen*/
9877 1, /*islwpn*/
9878 (ID==wWind?1:0) /*special*/
9879 )
9880 );
9881 ri->lwpn = Lwpns.spr(Lwpns.Count() - 1)->getUID();
9882
9883 weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //last created
9884 //w->LOADGFX(FFCore.getDefWeaponSprite(ID)); //What the fuck Zoria, this broke old quests...
9885 w->ScriptGenerated = 1;
9886 w->isLWeapon = 1;
9887 if(ID == wWind) w->specialinfo = 1;
9888 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //last created
9889 //w->LOADGFX(FFCore.getDefWeaponSprite(ID)); //not needed here because this has access to wpn->prent
9890 }
9891 else
9892 {
9893 Z_scripterrlog("Tried to create too many LWeapons on the screen. The current LWeapon count is: %d\n", Lwpns.Count());
9894 ri->lwpn = 0;
9895 }
9896
9897 /* Z_scripterrlog("CreateLWeaponDx ri->d[rINDEX] is (%i), trying to use for '%s'\n", ID, "ID");
9898 Z_scripterrlog("CreateLWeaponDx ri->d[rINDEX2] is (%i), trying to use for '%s'\n", itemid, "itemid");
9899 Z_scripterrlog("CreateLWeaponDx ri->lwpn is (%i), trying to use for '%s'\n", ri->lwpn, "ri->lwpn"); */
9900
9901 ret = ri->lwpn;
9902 }
9903 break;
9904
9905 /*
9906 //Screen->CollisionDx(int32_t enemy_index, int32_t lweapon_type, int32_t power, int32_t x, int32_t y, int32_t weapon_dir, int32_t parent_item);
9907 //Handles collision between an npc at screen index 'enemy_index', and an arbitrary lweapon that may or may not exist.
9908 //Does damage, and returns true a value collision is valid. Returns a different value otherwise.
9909
9910 // take damage or ignore it
9911 // -1: damage (if any) dealt
9912 // 1: blocked
9913 // 0: weapon passes through unhindered
9914 // 2: heal enemy? -ZoriaRPG
9915
9916 //THis function should automatically check for shields blocking the weapon, and calculate enemy defences.
9917 //In theory, scritped swords, and other melee weapons could use this, as coudl any weapon, and it may simplify
9918 //collision routines.
9919 case COLLISIONDX:
9920 {
9921 //Z_message("Trying to get Player->SetExtend().\n");
9922 int32_t index = (ri->d[rINDEX] / 10000);
9923 int32_t lweapon_type = (ri->d[rINDEX2] / 10000);
9924 int32_t power = (ri->d[rEXP1]/10000);
9925
9926 int32_t wpnx = ri->4[3]/10000, wpny = ri->d[rSFRAME]/10000;
9927 int32_t dir = ri->d[rNUL]/10000;
9928 int32_t parentitem = (ri->d[rSFTEMP]/10000);
9929 lweapon_type = vbound(lweapon_type,0,40); //Are we at 40, or higher now>
9930 parentitem = vbound(itemid,0,255);
9931
9932 //Log the stack events:
9933 Z_scripterrlog("CollisionDx ri->d[rINDEX] is (%i), trying to use for '%s'\n", index, "index");
9934 Z_scripterrlog("CollisionDx ri->d[rINDEX2] is (%i), trying to use for '%s'\n", lweapon_type, "lweapon_type");
9935 Z_scripterrlog("CollisionDx ri->d[rEXP1] is (%i), trying to use for '%s'\n", power, "power");
9936 Z_scripterrlog("CollisionDx ri->d[rEXP2] is (%i), trying to use for '%s'\n", wpnx, "wpnx");
9937 Z_scripterrlog("CollisionDx ri->d[rSFRAME] is (%i), trying to use for '%s'\n", wpny, "wpny");
9938 Z_scripterrlog("CollisionDx ri->d[rNUL] is (%i), trying to use for '%s'\n", dir, "dir");
9939 Z_scripterrlog("CollisionDx ri->d[rINDEX] is (%i), trying to use for '%s'\n", parentitem, "parentitem");
9940
9941 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,lweapon_type,0,power,dir,parentitem,-1,false);
9942 int32_t retval = ((enemy*)guys.spr(index))->takehit(w);
9943 //TakeHit, as I recall, applies damage and returns the hit status. Gold.
9944 delete w;
9945 ret = retval;
9946 }
9947 break;
9948
9949 */
9950 case DEBUGREFFFC:
9951 {
9952 int32_t r = -1;
9953 if ( ri->ffcref ) r = ri->ffcref;
9954 ret = r * 10000;
9955 break;
9956 }
9957
9958 case DEBUGREFITEM:
9959 {
9960 int32_t r = -1;
9961 if ( ri->itemref ) r = ri->itemref;
9962 ret = r * 10000;
9963 break;
9964 }
9965
9966 case DEBUGREFITEMDATA:
9967 {
9968 int32_t r = -1;
9969 if ( ri->idata ) r = ri->idata;
9970 ret = r * 10000;
9971 break;
9972 }
9973
9974 case DEBUGREFLWEAPON:
9975 {
9976 int32_t r = -1;
9977 if ( ri->lwpn ) r = ri->lwpn;
9978 ret = r * 10000;
9979 break;
9980 }
9981
9982 case DEBUGREFEWEAPON:
9983 {
9984 int32_t r = -1;
9985 if ( ri->ewpn ) r = ri->ewpn;
9986 ret = r * 10000;
9987 break;
9988 }
9989
9990 case DEBUGREFNPC:
9991 {
9992 int32_t r = -1;
9993 if ( ri->guyref ) r = ri->guyref;
9994 ret = r * 10000;
9995 break;
9996 }
9997
9998 case DEBUGSP:
9999 {
10000 ret = SH::read_stack(ri->sp) * 10000;
10001 break;
10002 }
10003 case DEBUGGDR:
10004 {
10005 int32_t a = vbound(ri->d[rINDEX]/10000,0,15);
10006 int32_t r = -1;
10007 if ( game->global_d[a] ) r = game->global_d[a];
10008 ret = r * 10000;
10009 break;
10010 }
10011
10012 ///----------------------------------------------------------------------------------------------------//
10013 //New Datatype Variables
10014
10015 ///----------------------------------------------------------------------------------------------------//
10016 //spritedata sp-> Variables
10017
10018 case SPRITEDATATILE: GET_SPRITEDATA_VAR_INT(tile, "Tile") break;
10019 case SPRITEDATAMISC: GET_SPRITEDATA_VAR_INT(misc, "Misc") break;
10020 case SPRITEDATACSETS:
10021 {
10022 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
10023 {
10024 ret = -10000;
10025 Z_scripterrlog("Invalid Sprite ID passed to spritedata->CSet: %d\n", (ri->spritesref*10000));
10026 }
10027 else
10028 ret = ((wpnsbuf[ri->spritesref].csets & 0xF) * 10000);
10029 break;
10030 }
10031 case SPRITEDATAFLCSET:
10032 {
10033 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
10034 {
10035 ret = -10000;
10036 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", (ri->spritesref*10000), "FlashCSet");
10037 break;
10038 }
10039 ret = (((wpnsbuf[ri->spritesref].csets & 0xF0)>>4) * 10000);
10040 break;
10041 }
10042 case SPRITEDATAFRAMES: GET_SPRITEDATA_VAR_INT(frames, "Frames") break;
10043 case SPRITEDATASPEED: GET_SPRITEDATA_VAR_INT(speed, "Speed") break;
10044 case SPRITEDATATYPE: GET_SPRITEDATA_VAR_INT(type, "Type") break;
10045 case SPRITEDATAFLAGS:
10046 {
10047 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
10048 {
10049 ret = 0;
10050 Z_scripterrlog("Invalid Sprite ID passed to spritedata->Flags[]: %d\n", (ri->spritesref*10000));
10051 break;
10052 }
10053 int32_t index = ri->d[rINDEX]/10000;
10054 if(unsigned(index) >= 5)
10055 {
10056 ret = 0;
10057 Z_scripterrlog("Invalid index passed to spritedata->Flags[]: %d\n", index);
10058 break;
10059 }
10060 ret = (wpnsbuf[ri->spritesref].misc & (1<<index)) ? 10000 : 0;
10061 break;
10062 }
10063 case SPRITEDATAID:
10064 {
10065 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
10066 {
10067 ret = -10000;
10068 Z_scripterrlog("Invalid Sprite ID passed to spritedata->ID: %d\n", (ri->spritesref*10000));
10069 break;
10070 }
10071 ret = ri->spritesref*10000;
10072 break;
10073 }
10074
10075 ///----------------------------------------------------------------------------------------------------//
10076 //mapdata m-> variables
10077 #define GET_MAPDATA_VAR_INT32(member, str) \
10078 { \
10079 if ( mapscr *m = GetMapscr(ri->mapsref) ) \
10080 { \
10081 ret = (m->member *10000); \
10082 } \
10083 else \
10084 { \
10085 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10086 ret = -10000; \
10087 } \
10088 } \
10089
10090 #define GET_MAPDATA_VAR_INT16(member, str) \
10091 { \
10092 if ( mapscr *m = GetMapscr(ri->mapsref) ) \
10093 { \
10094 ret = (m->member *10000); \
10095 } \
10096 else \
10097 { \
10098 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10099 ret = -10000; \
10100 } \
10101 } \
10102
10103 #define GET_MAPDATA_VAR_BYTE(member, str) \
10104 { \
10105 if ( mapscr *m = GetMapscr(ri->mapsref) ) \
10106 { \
10107 ret = (m->member *10000); \
10108 } \
10109 else \
10110 { \
10111 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10112 ret = -10000; \
10113 } \
10114 } \
10115
10116 #define GET_MAPDATA_VAR_INDEX32(member, str, indexbound) \
10117 { \
10118 int32_t indx = ri->d[rINDEX] / 10000; \
10119 if(indx < 0 || indx > indexbound ) \
10120 { \
10121 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
10122 ret = -10000; \
10123 } \
10124 else \
10125 { \
10126 if (mapscr *m = GetMapscr(ri->mapsref)) \
10127 { \
10128 ret = (m->member[indx] *10000); \
10129 } \
10130 else \
10131 { \
10132 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10133 ret = -10000; \
10134 } \
10135 } \
10136 } \
10137
10138 #define GET_MAPDATA_VAR_INDEX16(member, str, indexbound) \
10139 { \
10140 int32_t indx = ri->d[rINDEX] / 10000; \
10141 if(indx < 0 || indx > indexbound ) \
10142 { \
10143 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
10144 ret = -10000; \
10145 } \
10146 else \
10147 { \
10148 if (mapscr *m = GetMapscr(ri->mapsref)) \
10149 { \
10150 ret = (m->member[indx] *10000); \
10151 } \
10152 else \
10153 { \
10154 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10155 ret = -10000; \
10156 } \
10157 } \
10158 } \
10159
10160 #define GET_MAPDATA_BYTE_INDEX(member, str, indexbound) \
10161 { \
10162 int32_t indx = ri->d[rINDEX] / 10000; \
10163 if(indx < 0 || indx > indexbound ) \
10164 { \
10165 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
10166 ret = -10000; \
10167 } \
10168 else \
10169 { \
10170 if (mapscr *m = GetMapscr(ri->mapsref)) \
10171 { \
10172 ret = (m->member[indx] *10000); \
10173 } \
10174 else \
10175 { \
10176 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10177 ret = -10000; \
10178 } \
10179 } \
10180 } \
10181
10182 /*
10183 #define GET_MAPDATA_LAYER_INDEX(member, str, indexbound) \
10184 { \
10185 int32_t indx = ri->d[rINDEX] / 10000; \
10186 mapscr *m = GetMapscr(ri->mapsref); \
10187 if ( indx == 0 ) \
10188 { \
10189 \
10190 } \
10191 else \
10192 { \
10193 ret = (m->member[indx-1] *10000); \
10194 } \
10195 } \
10196 */
10197
10198 #define GET_MAPDATA_LAYER_INDEX(member, str, indexbound) \
10199 { \
10200 int32_t indx = ri->d[rINDEX] / 10000; \
10201 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
10202 if(indx < 1 || indx > indexbound ) \
10203 { \
10204 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
10205 ret = -10000; \
10206 } \
10207 else \
10208 { \
10209 if (mapscr *m = GetMapscr(ri->mapsref)) \
10210 { \
10211 ret = (m->member[indx-1] *10000); \
10212 } \
10213 else \
10214 { \
10215 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10216 ret = -10000; \
10217 } \
10218 } \
10219 } \
10220
10221 #define GET_MAPDATA_BOOL_INDEX(member, str, indexbound) \
10222 { \
10223 int32_t indx = ri->d[rINDEX] / 10000; \
10224 if(indx < 0 || indx > indexbound ) \
10225 { \
10226 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
10227 ret = -10000; \
10228 } \
10229 else \
10230 { \
10231 if (mapscr *m = GetMapscr(ri->mapsref)) \
10232 { \
10233 ret = (m->member[indx]?10000:0); \
10234 } \
10235 else \
10236 { \
10237 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10238 ret = -10000; \
10239 } \
10240 } \
10241 } \
10242
10243 #define GET_FFC_MAPDATA_BOOL_INDEX(member, str, indexbound) \
10244 { \
10245 int32_t indx = ri->d[rINDEX] / 10000; \
10246 if(indx < 0 || indx > indexbound ) \
10247 { \
10248 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
10249 ret = -10000; \
10250 } \
10251 else \
10252 { \
10253 if (mapscr *m = GetMapscr(ri->mapsref)) \
10254 { \
10255 ret = (m->ffcs[indx].member?10000:0); \
10256 } \
10257 else \
10258 { \
10259 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10260 ret = -10000; \
10261 } \
10262 } \
10263 } \
10264
10265 #define GET_MAPDATA_FLAG(member, str) \
10266 { \
10267 int32_t flag = (value/10000); \
10268 if (mapscr *m = GetMapscr(ri->mapsref)) \
10269 { \
10270 ret = (m->member&flag) ? 10000 : 0); \
10271 } \
10272 else \
10273 { \
10274 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10275 ret = -10000; \
10276 } \
10277 } \
10278
10279 #define GET_SCREENDATA_COMBO_VAR(member, str) \
10280 { \
10281 if (mapscr *m = GetMapscr(ri->mapsref)) \
10282 { \
10283 int32_t pos = ri->d[rINDEX] / 10000; \
10284 if(BC::checkComboPos(pos, str) != SH::_NoError) \
10285 ret = -10000; \
10286 else \
10287 ret = m->member[pos]*10000; \
10288 } \
10289 else \
10290 { \
10291 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10292 ret = -10000; \
10293 } \
10294 } \
10295
10296 #define GET_MAPDATA_COMBO_VAR_BUF(member, str) \
10297 { \
10298 if (mapscr *m = GetMapscr(ri->mapsref)) \
10299 { \
10300 int32_t pos = ri->d[rINDEX] / 10000; \
10301 if(BC::checkComboPos(pos, str) != SH::_NoError) \
10302 ret = -10000; \
10303 else \
10304 ret = combobuf[m->data[pos]].member * 10000; \
10305 } \
10306 else \
10307 { \
10308 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10309 ret = -10000; \
10310 } \
10311 } \
10312
10313 #define GET_MAPDATA_FFCPOS_INDEX32(member, str, indexbound) \
10314 { \
10315 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
10316 if(indx < 0 || indx > indexbound ) \
10317 { \
10318 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
10319 ret = -10000; \
10320 } \
10321 else if (mapscr *m = GetMapscr(ri->mapsref)) \
10322 { \
10323 ret = (m->ffcs[indx].member).getZLong(); \
10324 } \
10325 else \
10326 { \
10327 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
10328 ret = -10000; \
10329 } \
10330 } \
10331
10332 #define GET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
10333 { \
10334 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
10335 if(indx < 0 || indx > indexbound ) \
10336 { \
10337 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
10338 ret = -10000; \
10339 } \
10340 else if (mapscr *m = GetMapscr(ri->mapsref)) \
10341 { \
10342 ret = (m->ffcs[indx].member)*10000; \
10343 } \
10344 else \
10345 { \
10346 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
10347 ret = -10000; \
10348 } \
10349 } \
10350
10351 #define GET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
10352 { \
10353 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
10354 if(indx < 0 || indx > indexbound ) \
10355 { \
10356 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
10357 ret = -10000; \
10358 } \
10359 else if (mapscr *m = GetMapscr(ri->mapsref)) \
10360 { \
10361 ret = (m->ffcs[indx].member)*10000; \
10362 } \
10363 else \
10364 { \
10365 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
10366 ret = -10000; \
10367 } \
10368 } \
10369
10370 case LOADMAPDATA:
10371 6509791 ret=FFScript::loadMapData();
10372 6509791 break;
10373
10374 case NPCCOLLISION:
10375 ret=FFCore.npc_collision();
10376 break;
10377
10378 case NPCLINEDUP:
10379 ret=FFCore.npc_linedup();
10380 break;
10381
10382 case CREATEBITMAP:
10383 {
10384 146 ret=FFCore.do_create_bitmap();
10385 146 break;
10386 }
10387
10388
10389 case MAPDATAVALID: GET_MAPDATA_VAR_BYTE(valid, "Valid"); break; //b
10390 case MAPDATAGUY: GET_MAPDATA_VAR_BYTE(guy, "Guy"); break; //b
10391 case MAPDATASTRING: GET_MAPDATA_VAR_INT32(str, "String"); break; //w
10392 case MAPDATAROOM: GET_MAPDATA_VAR_BYTE(room, "RoomType"); break; //b
10393 case MAPDATAITEM:
10394 {
10395 if ( mapscr *m = GetMapscr(ri->mapsref) )
10396 {
10397 if(m->hasitem)
10398 ret = (m->item *10000);
10399 else ret = -10000;
10400 }
10401 else
10402 {
10403 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Item"); \
10404 ret = -10000;
10405 }
10406 break;
10407 }
10408 case MAPDATAHASITEM: GET_MAPDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
10409 case MAPDATATILEWARPTYPE: GET_MAPDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
10410 //case MAPDATATILEWARPOVFLAGS: GET_MAPDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
10411 case MAPDATADOORCOMBOSET: GET_MAPDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
10412 case MAPDATAWARPRETX: GET_MAPDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
10413 case MAPDATAWARPRETY: GET_MAPDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
10414 case MAPDATAWARPRETURNC: GET_MAPDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
10415 case MAPDATASTAIRX: GET_MAPDATA_VAR_BYTE(stairx, "StairsX"); break; //b
10416 case MAPDATASTAIRY: GET_MAPDATA_VAR_BYTE(stairy, "StairsY"); break; //b
10417 case MAPDATAITEMX: GET_MAPDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
10418 case MAPDATAITEMY: GET_MAPDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
10419 case MAPDATACOLOUR: GET_MAPDATA_VAR_INT32(color, "CSet"); break; //w
10420 case MAPDATAENEMYFLAGS: GET_MAPDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
10421 case MAPDATADOOR: GET_MAPDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
10422 case MAPDATATILEWARPDMAP: GET_MAPDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
10423 case MAPDATATILEWARPSCREEN: GET_MAPDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
10424 case MAPDATAEXITDIR: GET_MAPDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
10425 case MAPDATAENEMY: GET_MAPDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
10426 case MAPDATAPATTERN: GET_MAPDATA_VAR_BYTE(pattern, "Pattern"); break; //b
10427 case MAPDATASIDEWARPTYPE: GET_MAPDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
10428 //case MAPDATASIDEWARPOVFLAGS: GET_MAPDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
10429 case MAPDATAWARPARRIVALX: GET_MAPDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
10430 case MAPDATAWARPARRIVALY: GET_MAPDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
10431 case MAPDATAPATH: GET_MAPDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
10432 case MAPDATASIDEWARPSC: GET_MAPDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
10433 case MAPDATAINITD: GET_MAPDATA_VAR_INDEX32(screeninitd, "InitD", 8); break; //w, 4 of these
10434 case MAPDATASIDEWARPDMAP: GET_MAPDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
10435 case MAPDATASIDEWARPINDEX: GET_MAPDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
10436 case MAPDATAUNDERCOMBO: GET_MAPDATA_VAR_INT32(undercombo, "UnderCombo"); break; //w
10437 case MAPDATAUNDERCSET: GET_MAPDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
10438 case MAPDATACATCHALL: GET_MAPDATA_VAR_INT32(catchall, "Catchall"); break; //W
10439
10440 case MAPDATACSENSITIVE: GET_MAPDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
10441 case MAPDATANORESET: GET_MAPDATA_VAR_INT32(noreset, "NoReset"); break; //W
10442 case MAPDATANOCARRY: GET_MAPDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
10443
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
12 case MAPDATALAYERMAP: GET_MAPDATA_LAYER_INDEX(layermap, "LayerMap", 6); break; //B, 6 OF THESE
10444
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
12 case MAPDATALAYERSCREEN: GET_MAPDATA_LAYER_INDEX(layerscreen, "LayerScreen", 6); break; //B, 6 OF THESE
10445 case MAPDATALAYEROPACITY: GET_MAPDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 6); break; //B, 6 OF THESE
10446 case MAPDATATIMEDWARPTICS: GET_MAPDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
10447 case MAPDATANEXTMAP: GET_MAPDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
10448 case MAPDATANEXTSCREEN: GET_MAPDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
10449
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
256 case MAPDATASECRETCOMBO: GET_MAPDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
10450
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
256 case MAPDATASECRETCSET: GET_MAPDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
10451
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
256 case MAPDATASECRETFLAG: GET_MAPDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
10452
10453 case MAPDATAVIEWX: break;//GET_MAPDATA_VAR_INT32(viewX, "ViewX"); break; //W
10454 case MAPDATASCRIPT: GET_MAPDATA_VAR_INT32(script, "Script"); break; //W
10455 case MAPDATAVIEWY: break;//GET_MAPDATA_VAR_INT32(viewY, "ViewY"); break; //W
10456 case MAPDATASCREENWIDTH: break;//GET_MAPDATA_VAR_BYTE(scrWidth, "Width"); break; //B
10457 case MAPDATASCREENHEIGHT: break;//GET_MAPDATA_VAR_BYTE(scrHeight, "Height"); break; //B
10458 case MAPDATAENTRYX: GET_MAPDATA_VAR_BYTE(entry_x, "EntryX"); break; //B
10459 case MAPDATAENTRYY: GET_MAPDATA_VAR_BYTE(entry_y, "EntryY"); break; //B
10460
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFDATA: GET_MAPDATA_FFC_INDEX32(data, "FFCData", MAXFFCS-1); break; //W, MAXFFCS OF THESE
10461
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFCSET: GET_MAPDATA_FFC_INDEX32(cset, "FFCCSet", MAXFFCS-1); break; //B, MAXFFCS
10462
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFDELAY: GET_MAPDATA_FFC_INDEX32(delay, "FFCDelay", MAXFFCS-1); break; //W, MAXFFCS
10463
3/6
✓ Branch 0 taken 389 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 389 times.
✓ Branch 4 taken 389 times.
✗ Branch 5 not taken.
778 case MAPDATAFFX: GET_MAPDATA_FFCPOS_INDEX32(x, "FFCX", MAXFFCS-1); break; //INT32, MAXFFCS OF THESE
10464
3/6
✓ Branch 0 taken 389 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 389 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 389 times.
778 case MAPDATAFFY: GET_MAPDATA_FFCPOS_INDEX32(y, "FFCY", MAXFFCS-1); break; //..
10465
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFXDELTA: GET_MAPDATA_FFCPOS_INDEX32(vx, "FFCVx", MAXFFCS-1); break; //..
10466
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFYDELTA: GET_MAPDATA_FFCPOS_INDEX32(vy, "FFCVy", MAXFFCS-1); break; //..
10467
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
10 case MAPDATAFFXDELTA2: GET_MAPDATA_FFCPOS_INDEX32(ax, "FFCAx", MAXFFCS-1); break; //..
10468
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
10 case MAPDATAFFYDELTA2: GET_MAPDATA_FFCPOS_INDEX32(ay, "FFCAy", MAXFFCS-1); break; //..
10469
3/6
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
140 case MAPDATAFFFLAGS: GET_MAPDATA_FFC_INDEX32(flags, "FFCFlags", MAXFFCS-1); break; //INT16, MAXFFCS OF THESE
10470 case MAPDATASIDEWARPID:
10471 {
10472 int32_t indx = ri->d[rINDEX] / 10000;
10473 if (mapscr *m = GetMapscr(ri->mapsref))
10474 {
10475 ret = (((m->flags2 >> indx) & 1)
10476 ? (m->sidewarpindex >> (2*indx)) & 3 //Return which warp is set
10477 : -1 //Returns -1 if no warp is set
10478 )*10000;
10479 }
10480 else
10481 {
10482 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","SideWarpID");
10483 ret = -10000;
10484 }
10485 break;
10486 }
10487 //Number of ffcs that are in use (have valid data
10488 case MAPDATANUMFF:
10489 {
10490 32 uint32_t indx = ri->d[rINDEX] / 10000;
10491
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
32 if (!indx || indx > MAXFFCS)
10492 {
10493 Z_scripterrlog("Invalid Index passed to mapdata->NumFFCs[%d].\n Valid indices are 1 through %d.\n", indx, MAXFFCS);
10494 ret = 0;
10495 }
10496
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 else if (mapscr *m = GetMapscr(ri->mapsref))
10497 {
10498 32 --indx;
10499 32 ret = (m->ffcs[indx].data != 0) ? 10000 : 0;
10500 32 }
10501 else
10502 {
10503 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
10504 ret = 0;
10505 }
10506 32 break;
10507 }
10508
10509 case MAPDATATILEWARPOVFLAGS:
10510 {
10511 int32_t indx = ri->d[rINDEX] / 10000;
10512 if ( ((unsigned)indx) > 3 )
10513 {
10514 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
10515 ret = 0;
10516 }
10517 else if (mapscr *m = GetMapscr(ri->mapsref))
10518 {
10519 ret = (m->tilewarpoverlayflags & (1<<indx))?10000:0;
10520 }
10521 else
10522 {
10523 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
10524 ret = 0;
10525 }
10526 break;
10527 }
10528
10529 case MAPDATASIDEWARPOVFLAGS:
10530 {
10531 int32_t indx = ri->d[rINDEX] / 10000;
10532 if ( ((unsigned)indx) > 3 )
10533 {
10534 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
10535 ret = 0;
10536 }
10537 else if (mapscr *m = GetMapscr(ri->mapsref))
10538 {
10539 ret = (m->sidewarpoverlayflags & (1<<indx))?10000:0;
10540 }
10541 else
10542 {
10543 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
10544 ret = 0;
10545 }
10546 break;
10547 }
10548
10549 case MAPDATATWARPRETSQR:
10550 {
10551 int32_t indx = ri->d[rINDEX] / 10000;
10552 if ( ((unsigned)indx) > 3)
10553 {
10554 ret = -10000;
10555 Z_scripterrlog("Invalid Array Index passed to mapdata->TileWarpReturnSquare[]: %d\n", indx);
10556
10557 }
10558 else if (mapscr *m = GetMapscr(ri->mapsref))
10559 {
10560 ret = ((m->warpreturnc>>(indx*2))&3) * 10000;
10561 }
10562 else
10563 {
10564 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
10565 ret = -10000;
10566 }
10567 break;
10568 }
10569
10570 case MAPDATASWARPRETSQR:
10571 {
10572 int32_t indx = ri->d[rINDEX] / 10000;
10573 if ( ((unsigned)indx) > 3)
10574 {
10575 ret = -10000;
10576 Z_scripterrlog("Invalid Array Index passed to mapdata->TileWarpReturnSquare[]: %d\n", indx);
10577
10578 }
10579 else if (mapscr *m = GetMapscr(ri->mapsref))
10580 {
10581 ret = ((m->warpreturnc>>(8+(indx*2)))&3) * 10000;
10582 }
10583 else
10584 {
10585 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
10586 ret = -10000;
10587 }
10588 break;
10589 }
10590
10591 case MAPDATAFFWIDTH:
10592 {
10593
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (mapscr *m = GetMapscr(ri->mapsref))
10594 {
10595 5 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10596
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if ( indx < 0 || indx > MAXFFCS-1 )
10597 {
10598 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileWidth[]: %d\n", indx+1);
10599 ret = -10000;
10600 break;
10601 }
10602 5 ret=(m->ffTileWidth(indx))*10000;
10603 5 }
10604 else
10605 {
10606 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileWidth[]");
10607 ret = -10000;
10608 }
10609 5 break;
10610 }
10611
10612 case MAPDATAFFHEIGHT:
10613 {
10614
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (mapscr *m = GetMapscr(ri->mapsref))
10615 {
10616 5 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10617
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if ( indx < 0 || indx > MAXFFCS-1 )
10618 {
10619 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileHeight[]: %d\n", indx+1);
10620 ret = -10000;
10621 break;
10622 }
10623 5 ret=(m->ffTileHeight(indx))*10000;
10624 5 }
10625 else
10626 {
10627 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileHeight[]");
10628 ret = -10000;
10629 }
10630 5 break;
10631
10632 }
10633
10634 case MAPDATAFFEFFECTWIDTH:
10635 {
10636
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (mapscr *m = GetMapscr(ri->mapsref))
10637 {
10638 5 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10639
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if ( indx < 0 || indx > MAXFFCS-1 )
10640 {
10641 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectWidth[]: %d\n", indx+1);
10642 ret = -10000;
10643 break;
10644 }
10645 5 ret=(m->ffEffectWidth(indx))*10000;
10646 5 }
10647 else
10648 {
10649 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectWidth[]");
10650 ret = -10000;
10651 }
10652 5 break;
10653 }
10654
10655 case MAPDATAFFEFFECTHEIGHT:
10656 {
10657
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (mapscr *m = GetMapscr(ri->mapsref))
10658 {
10659 5 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10660
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if ( indx < 0 || indx > MAXFFCS-1 )
10661 {
10662 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectHeight[]: %d\n", indx+1);
10663 ret = -10000;
10664 break;
10665 }
10666 5 ret=(m->ffEffectHeight(indx))*10000;
10667 5 }
10668 else
10669 {
10670 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectHeight[]");
10671 ret = -10000;
10672 }
10673 5 break;
10674 }
10675
10676
10677 case MAPDATAFFLINK: GET_MAPDATA_FFC_INDEX32(link, "FFCLink", MAXFFCS-1); break; //B, MAXFFCS OF THESE
10678
3/6
✓ Branch 0 taken 32773 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32773 times.
✓ Branch 4 taken 32773 times.
✗ Branch 5 not taken.
65546 case MAPDATAFFSCRIPT: GET_MAPDATA_FFC_INDEX32(script, "FFCScript", MAXFFCS-1); break; //W, MAXFFCS OF THESE
10679
10680 case MAPDATAINTID: //Same form as SetScreenD()
10681 //SetFFCInitD(ffindex, d, value)
10682 {
10683
1/2
✓ Branch 0 taken 1800 times.
✗ Branch 1 not taken.
1800 if (mapscr *m = GetMapscr(ri->mapsref))
10684 {
10685 1800 int32_t ffid = (ri->d[rINDEX]/10000) -1;
10686 1800 int32_t indx = ri->d[rINDEX2]/10000;
10687
10688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1800 times.
1800 if ( (unsigned)ffid > MAXFFCS-1 )
10689 {
10690 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
10691 ret = -10000;
10692 }
10693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1800 times.
1800 else if ( (unsigned)indx > 7 )
10694 {
10695 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
10696 ret = -10000;
10697 }
10698 else
10699 {
10700 1800 ret = (m->ffcs[ffid].initd[indx]);
10701 }
10702
10703 //int32_t ffindex = ri->d[rINDEX]/10000;
10704 //int32_t d = ri->d[rINDEX2]/10000;
10705 //int32_t v = (value/10000);
10706 1800 }
10707 else
10708 {
10709 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","GetFFCInitD()");
10710 ret = -10000;
10711 }
10712 1800 break;
10713 }
10714
10715
10716
10717 //initd //INT32 , 32 OF THESE, EACH WITH 10 INDICES.
10718
10719 case MAPDATAINITA:
10720 //same form as SetScreenD
10721 {
10722 if (mapscr *m = GetMapscr(ri->mapsref))
10723 {
10724 //int32_t ffindex = ri->d[rINDEX]/10000;
10725 //int32_t d = ri->d[rINDEX2]/10000;
10726 //int32_t v = (value/10000);
10727
10728 int32_t ffid = (ri->d[rINDEX]/10000) -1;
10729 int32_t indx = ri->d[rINDEX2]/10000;
10730
10731 if ( (unsigned)ffid > MAXFFCS-1 )
10732 {
10733 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
10734 ret = -10000;
10735 }
10736 else if ( (unsigned)indx > 1 )
10737 {
10738 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
10739 ret = -10000;
10740 }
10741 else
10742 {
10743 ret = (m->ffcs[ffid].inita[indx]);
10744 }
10745 }
10746 else
10747 {
10748 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","GetFFCInitD()");
10749 ret = -10000;
10750 }
10751 break;
10752 }
10753
10754 //inita //INT32, 32 OF THESE, EACH WITH 2
10755
10756 case MAPDATAFFINITIALISED:
10757 {
10758 int32_t indx = ri->d[rINDEX] / 10000;
10759 if (indx < 0 || indx > MAXFFCS-1)
10760 {
10761 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", "FFCRunning", indx);
10762 ret = -10000;
10763 }
10764 else
10765 {
10766 if (mapscr *m = GetMapscr(ri->mapsref))
10767 {
10768 ret = get_script_engine_data(ScriptType::FFC, indx).initialized ? 10000 : 0;
10769 }
10770 else
10771 {
10772 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n", "FFCRunning");
10773 ret = -10000;
10774 }
10775 }
10776 }
10777 break;
10778
10779 case MAPDATASCRIPTENTRY: GET_MAPDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
10780 case MAPDATASCRIPTOCCUPANCY: GET_MAPDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
10781 case MAPDATASCRIPTEXIT: GET_MAPDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
10782 case MAPDATAOCEANSFX: GET_MAPDATA_VAR_BYTE(oceansfx, "OceanSFX"); break; //B
10783 case MAPDATABOSSSFX: GET_MAPDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
10784 case MAPDATASECRETSFX: GET_MAPDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
10785 case MAPDATAHOLDUPSFX: GET_MAPDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
10786 case MAPDATASCREENMIDI:
10787 {
10788 if (mapscr *m = GetMapscr(ri->mapsref))
10789 {
10790 ret = ((m->screen_midi+(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT)) *10000);
10791 }
10792 else
10793 {
10794 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","MIDI");
10795 ret = -10000;
10796 }
10797 break;
10798 }
10799 case MAPDATALENSLAYER: GET_MAPDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
10800 case MAPDATAMAP:
10801 {
10802 if (mapscr *m = GetMapscr(ri->mapsref))
10803 {
10804 ret = getMap(ri->mapsref) * 10000;
10805 }
10806 else
10807 {
10808 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Map");
10809 ret = -10000;
10810 }
10811 break;
10812 }
10813 case MAPDATASCREEN:
10814 {
10815 if (mapscr *m = GetMapscr(ri->mapsref))
10816 {
10817 ret = getScreen(ri->mapsref) * 10000;
10818 }
10819 else
10820 {
10821 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Screen");
10822 ret = -10000;
10823 }
10824 break;
10825 }
10826
10827 case MAPDATAFLAGS:
10828 {
10829 if(mapscr *m = GetMapscr(ri->mapsref))
10830 {
10831 if ( get_qr(qr_OLDMAPDATAFLAGS) )
10832 {
10833 ret = get_screenflags(m,vbound(ri->d[rINDEX] / 10000,0,9));
10834 }
10835 else
10836 {
10837 int32_t flagid = (ri->d[rINDEX])/10000;
10838 //bool valtrue = ( value ? 10000 : 0);
10839 switch(flagid)
10840 {
10841 case 0: ret = (m->flags * 10000); break;
10842 case 1: ret = (m->flags2 * 10000); break;
10843 case 2: ret = (m->flags3 * 10000); break;
10844 case 3: ret = (m->flags4 * 10000); break;
10845 case 4: ret = (m->flags5 * 10000); break;
10846 case 5: ret = (m->flags6 * 10000); break;
10847 case 6: ret = (m->flags7 * 10000); break;
10848 case 7: ret = (m->flags8 * 10000); break;
10849 case 8: ret = (m->flags9 * 10000); break;
10850 case 9: ret = (m->flags10 * 10000); break;
10851 default:
10852 {
10853 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
10854 ret = -10000;
10855 break;
10856
10857 }
10858 }
10859 }
10860 }
10861 else
10862 {
10863 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Flags[]");
10864 ret = -10000;
10865 }
10866
10867 break;
10868 //GET_MAPDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
10869 }
10870
10871 case MAPDATAMISCD:
10872 {
10873 int32_t indx = (ri->d[rINDEX])/10000;
10874 int32_t mi = get_mi(ri->mapsref);
10875 if(unsigned(mi) >= MAX_MI)
10876 {
10877 ret = 0;
10878 break;
10879 }
10880 if( ((unsigned)indx) > 7 )
10881 {
10882 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", indx);
10883 ret = -10000;
10884 }
10885 else if (mapscr *m = GetMapscr(ri->mapsref))
10886 {
10887 ret = (game->screen_d[mi][indx]) * 10000;
10888 }
10889 else
10890 {
10891 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","D[]");
10892 ret = -10000;
10893 }
10894 break;
10895 }
10896
10897 case MAPDATACOMBODD:
10898 {
10899
1/2
✓ Branch 0 taken 4767898 times.
✗ Branch 1 not taken.
4767898 if (mapscr *m = GetMapscr(ri->mapsref))
10900 {
10901 4767898 int32_t pos = ri->d[rINDEX] / 10000;
10902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4767898 times.
4767898 if(BC::checkComboPos(pos, "mapdata->ComboD[pos]") != SH::_NoError)
10903 {
10904 ret = -10000;
10905 }
10906 else
10907 {
10908 4767898 ret = m->data[pos] * 10000;
10909 }
10910 4767898 }
10911 else
10912 {
10913 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboD[]",ri->mapsref);
10914 ret = -10000;
10915 }
10916 4767898 break;
10917 //GET_SCREENDATA_COMBO_VAR(data, "mapdata->ComboD") break;
10918 }
10919
10920 case MAPDATACOMBOCD:
10921 {
10922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4654485 times.
4654485 if (mapscr *m = GetMapscr(ri->mapsref))
10923 {
10924 //int32_t ffindex = ri->d[rINDEX]/10000;
10925 //int32_t d = ri->d[rINDEX2]/10000;
10926 //int32_t v = (value/10000);
10927 4654485 int32_t pos = ri->d[rINDEX] / 10000;
10928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4654485 times.
4654485 if(BC::checkComboPos(pos, "mapdata->ComboC[pos]") != SH::_NoError)
10929 {
10930 ret = -10000;
10931 }
10932 else
10933 {
10934 4654485 ret = m->cset[pos] * 10000;
10935 }
10936 4654485 }
10937 else
10938 {
10939 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboC[]",ri->mapsref);
10940 ret = -10000;
10941 }
10942 4654485 break;
10943 }
10944 //GET_SCREENDATA_COMBO_VAR(cset, "mapdata->ComboC") break;
10945
10946 case MAPDATACOMBOFD:
10947 {
10948
1/2
✓ Branch 0 taken 5945377 times.
✗ Branch 1 not taken.
5945377 if (mapscr *m = GetMapscr(ri->mapsref))
10949 {
10950 //int32_t ffindex = ri->d[rINDEX]/10000;
10951 //int32_t d = ri->d[rINDEX2]/10000;
10952 //int32_t v = (value/10000);
10953 5945377 int32_t pos = ri->d[rINDEX] / 10000;
10954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5945377 times.
5945377 if(BC::checkComboPos(pos, "mapdata->ComboF[pos]") != SH::_NoError)
10955 {
10956 ret = -10000;
10957 }
10958 else
10959 {
10960 5945377 ret = m->sflag[pos] * 10000;
10961 }
10962 5945377 }
10963 else
10964 {
10965 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboF[]",ri->mapsref);
10966 ret = -10000;
10967 }
10968 5945377 break;
10969 }
10970 //GET_SCREENDATA_COMBO_VAR(sflag, "mapdata->ComboF") break;
10971
10972
10973
10974 case MAPDATACOMBOTD:
10975 {
10976
1/2
✓ Branch 0 taken 2538431 times.
✗ Branch 1 not taken.
2538431 if (mapscr *m = GetMapscr(ri->mapsref))
10977 {
10978 //int32_t ffindex = ri->d[rINDEX]/10000;
10979 //int32_t d = ri->d[rINDEX2]/10000;
10980 //int32_t v = (value/10000);
10981 2538431 int32_t pos = ri->d[rINDEX] / 10000;
10982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2538431 times.
2538431 if(BC::checkComboPos(pos, "mapdata->ComboT[pos]") != SH::_NoError)
10983 {
10984 ret = -10000;
10985
10986 }
10987 else
10988 {
10989 2538431 ret = combobuf[m->data[pos]].type * 10000;
10990 }
10991 2538431 }
10992 else
10993 {
10994 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboT[]",ri->mapsref);
10995 ret = -10000;
10996 }
10997 2538431 break;
10998 }
10999 //GET_MAPDATA_COMBO_VAR_BUF(type, "mapdata->ComboT") break;
11000
11001 case MAPDATACOMBOID:
11002 {
11003
1/2
✓ Branch 0 taken 345816 times.
✗ Branch 1 not taken.
345816 if (mapscr *m = GetMapscr(ri->mapsref))
11004 {
11005 //int32_t ffindex = ri->d[rINDEX]/10000;
11006 //int32_t d = ri->d[rINDEX2]/10000;
11007 //int32_t v = (value/10000);
11008 345816 int32_t pos = ri->d[rINDEX] / 10000;
11009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 345816 times.
345816 if(BC::checkComboPos(pos, "mapdata->ComboI[pos]") != SH::_NoError)
11010 {
11011 ret = -10000;
11012 }
11013 else
11014 {
11015 345816 ret = combobuf[m->data[pos]].flag * 10000;
11016 }
11017 345816 }
11018 else
11019 {
11020 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboI[]",ri->mapsref);
11021 ret = -10000;
11022 }
11023 345816 break;
11024 //GET_SCREENDATA_COMBO_VAR(data, "mapdata->ComboD") break;
11025 }
11026 //GET_MAPDATA_COMBO_VAR_BUF(flag, "mapdata->ComboI") break;
11027
11028 case MAPDATACOMBOSD:
11029 {
11030
1/2
✓ Branch 0 taken 85947 times.
✗ Branch 1 not taken.
85947 if (mapscr *m = GetMapscr(ri->mapsref))
11031 {
11032 //int32_t ffindex = ri->d[rINDEX]/10000;
11033 //int32_t d = ri->d[rINDEX2]/10000;
11034 //int32_t v = (value/10000);
11035 85947 int32_t pos = ri->d[rINDEX] / 10000;
11036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85947 times.
85947 if(BC::checkComboPos(pos, "mapdata->ComboS[pos]") != SH::_NoError)
11037 {
11038 ret = -10000;
11039 }
11040 else
11041 {
11042 85947 ret = (combobuf[m->data[pos]].walk & 0xF) * 10000;
11043 }
11044 85947 }
11045 else
11046 {
11047 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboS[]", ri->mapsref);
11048 ret = -10000;
11049 }
11050 85947 break;
11051 }
11052
11053 case MAPDATACOMBOED:
11054 {
11055 if (mapscr *m = GetMapscr(ri->mapsref))
11056 {
11057 //int32_t ffindex = ri->d[rINDEX]/10000;
11058 //int32_t d = ri->d[rINDEX2]/10000;
11059 //int32_t v = (value/10000);
11060 int32_t pos = ri->d[rINDEX] / 10000;
11061 if(BC::checkComboPos(pos, "mapdata->ComboE[pos]") != SH::_NoError)
11062 {
11063 ret = -10000;
11064 }
11065 else
11066 {
11067 ret = ((combobuf[m->data[pos]].walk & 0xF0)>>4) * 10000;
11068 }
11069 }
11070 else
11071 {
11072 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboE[]", ri->mapsref);
11073 ret = -10000;
11074 }
11075 break;
11076 }
11077
11078 case MAPDATASCREENSTATED:
11079 {
11080 if (mapscr *m = GetMapscr(ri->mapsref))
11081 {
11082 int32_t mi = get_mi(ri->mapsref);
11083 if(mi<0) {ret = 0;break;}
11084 ret=((game->maps[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
11085 }
11086 else
11087 {
11088 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","State[]", ri->mapsref);
11089 ret = 0;
11090 }
11091 break;
11092 }
11093 case MAPDATAEXSTATED:
11094 {
11095 if (mapscr *m = GetMapscr(ri->mapsref))
11096 {
11097 int32_t mi = get_mi(ri->mapsref);
11098 if(mi<0) {ret = 0;break;}
11099 ret=((game->xstates[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
11100 }
11101 else
11102 {
11103 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","State[]", ri->mapsref);
11104 ret = 0;
11105 }
11106 break;
11107 }
11108 case MAPDATALENSSHOWS:
11109 {
11110 ret = 0;
11111 int ind = ri->d[rINDEX]/10000;
11112 if(ind < 0 || ind > 6)
11113 Z_scripterrlog("Bad index mapdata->LensShows[%d]\n",ind);
11114 else if(mapscr *m = GetMapscr(ri->mapsref))
11115 ret = (m->lens_show & (1<<ind)) ? 10000 : 0;
11116 else Z_scripterrlog("mapdata->LensShows[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
11117 break;
11118 }
11119 case MAPDATALENSHIDES:
11120 {
11121 ret = 0;
11122 int ind = ri->d[rINDEX]/10000;
11123 if(ind < 0 || ind > 6)
11124 Z_scripterrlog("Bad index mapdata->LensHides[%d]\n",ind);
11125 else if(mapscr *m = GetMapscr(ri->mapsref))
11126 ret = (m->lens_hide & (1<<ind)) ? 10000 : 0;
11127 else Z_scripterrlog("mapdata->LensHides[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
11128 break;
11129 }
11130 case MAPDATASCRDATASIZE:
11131 {
11132 ret = -10000;
11133 if(mapscr *m = GetMapscr(ri->mapsref))
11134 {
11135 auto mi = get_total_mi(ri->mapsref);
11136 if(mi < 0) break;
11137 ret = 10000*game->scriptDataSize(mi);
11138 }
11139 else Z_scripterrlog("mapdata->DataSize pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
11140 break;
11141 }
11142 case MAPDATASCRDATA:
11143 {
11144 ret = -10000;
11145 if(mapscr *m = GetMapscr(ri->mapsref))
11146 {
11147 auto mi = get_total_mi(ri->mapsref);
11148 if(mi < 0) break;
11149 size_t indx = ri->d[rINDEX]/10000;
11150 if(indx >= game->scriptDataSize(mi))
11151 Z_scripterrlog("Invalid index passed to mapdata->Data[]: %d\n", indx);
11152 else ret = game->screen_data[mi][indx];
11153 }
11154 else Z_scripterrlog("mapdata->Data[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
11155 break;
11156 }
11157 case MAPDATASCREENFLAGSD:
11158 {
11159 if(mapscr *m = GetMapscr(ri->mapsref))
11160 {
11161 ret = get_screenflags(m,vbound(ri->d[rINDEX] / 10000,0,9));
11162 }
11163 else
11164 {
11165 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","SFlags[]", ri->mapsref);
11166 ret = -10000;
11167 }
11168 break;
11169 }
11170
11171 case MAPDATASCREENEFLAGSD:
11172 {
11173 if(mapscr *m = GetMapscr(ri->mapsref))
11174 {
11175 ret = get_screeneflags(m,vbound(ri->d[rINDEX] / 10000,0,2));
11176 }
11177 else
11178 {
11179 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","EFlags[]", ri->mapsref);
11180 ret = -10000;
11181 }
11182 break;
11183 }
11184 case MAPDATAGUYCOUNT:
11185 {
11186 if(mapscr *m = GetMapscr(ri->mapsref))
11187 {
11188 int mi = get_mi(ri->mapsref);
11189 if(mi > -1)
11190 {
11191 ret = game->guys[mi] * 10000;
11192 break;
11193 }
11194 }
11195 ret = -10000;
11196 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","GuyCount", ri->mapsref);
11197 break;
11198 }
11199
11200 ///----------------------------------------------------------------------------------------------------//
11201 //shopdata sd-> variables
11202
11203 case SHOPDATATYPE:
11204 {
11205 int32_t ref = ri->shopsref;
11206 if ( ref > NUMINFOSHOPS || ref < 0 ) ret = 0;
11207 else ret = ( ( ref <= NUMSHOPS ) ? 10000 : 20000 );
11208 break;
11209 }
11210 case SHOPDATAITEM:
11211 {
11212
11213 int32_t ref = ri->shopsref;
11214 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
11215 int32_t indx = ri->d[rINDEX] / 10000;
11216 if ( indx < 0 || indx > 2 )
11217 {
11218 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Item");
11219 ret = -10000;
11220 }
11221 else
11222 {
11223 if ( isInfo )
11224 {
11225 Z_scripterrlog("Attempted to load an 'item' from an infoshop, using shop ID: %d\n", ri->shopsref);
11226 ret = -10000;
11227 }
11228 else
11229 {
11230 ret = ((int32_t)(QMisc.shop[ref].item[indx]) * 10000);
11231 }
11232 }
11233 break;
11234 }
11235
11236
11237 // GET_SHOPDATA_VAR_INDEX(item, "Item", 2); break;
11238 case SHOPDATAHASITEM:
11239 {
11240
11241 int32_t ref = ri->shopsref;
11242 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
11243 int32_t indx = ri->d[rINDEX] / 10000;
11244 if ( indx < 0 || indx > 2 )
11245 {
11246 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "HasItem");
11247 ret = -10000;
11248 }
11249 else
11250 {
11251 if ( isInfo )
11252 {
11253 Z_scripterrlog("Attempted to load 'hasitem' from an infoshop, using shop ID: %d\n", ri->shopsref);
11254 ret = -10000;
11255 }
11256 else
11257 {
11258 ret = ((int32_t)(QMisc.shop[ref].hasitem[indx]) * 10000);
11259 }
11260 }
11261 break;
11262 }
11263
11264
11265 //GET_SHOPDATA_VAR_INDEX(hasitem, "HasItem", 2); break;
11266 case SHOPDATAPRICE:
11267 {
11268
11269 int32_t ref = ri->shopsref;
11270 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
11271 int32_t indx = ri->d[rINDEX] / 10000;
11272 if ( indx < 0 || indx > 2 )
11273 {
11274 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Price");
11275 ret = -10000;
11276 }
11277 else
11278 {
11279 if ( isInfo )
11280 {
11281 ret = ((int32_t)(QMisc.info[ref - NUMSHOPS].price[indx]) * 10000);
11282 }
11283 else
11284 {
11285 ret = ((int32_t)(QMisc.shop[ref].price[indx]) * 10000);
11286 }
11287 }
11288 break;
11289 }
11290
11291
11292 //GET_SHOPDATA_VAR_INDEX(price, "Price", 2); break;
11293 //Pay for info
11294 case SHOPDATASTRING:
11295 {
11296 int32_t ref = ri->shopsref;
11297 if (ref < NUMSHOPS || ref > NUMINFOSHOPS)
11298 {
11299 Z_scripterrlog("Invalid shop pointer passed to shopdata->String[]: %d\n", ref);
11300 ret = -10000;
11301 }
11302 else
11303 {
11304 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
11305 int32_t indx = ri->d[rINDEX] / 10000;
11306 if ( indx < 0 || indx > 2 )
11307 {
11308 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "String");
11309 }
11310 else
11311 {
11312 if ( isInfo )
11313 {
11314 ret = ((int32_t)(QMisc.info[ref - NUMSHOPS].str[indx]) * 10000);
11315 }
11316 else
11317 {
11318 ret = ((int32_t)(QMisc.shop[ref].str[indx]) * 10000);
11319 }
11320 }
11321
11322
11323 }
11324
11325 //GET_SHOPDATA_VAR_INDEX(str, String, 2); break;
11326 break;
11327 }
11328
11329
11330 ///----------------------------------------------------------------------------------------------------//
11331 //dmapdata dmd-> variables
11332
11333 //getter
11334 case DMAPDATAID: ret = ri->dmapsref*10000; break; //read-only, equal to CurrentDMap
11335
11336 case DMAPDATAMAP: //byte
11337 {
11338 ret = ((byte)DMaps[ri->dmapsref].map + 1) * 10000; break;
11339 }
11340 case DMAPDATALEVEL: //word
11341 {
11342 ret = ((word)DMaps[ri->dmapsref].level) * 10000; break;
11343 }
11344 case DMAPDATAOFFSET: //char
11345 {
11346 ret = ((char)DMaps[ri->dmapsref].xoff) * 10000; break;
11347 }
11348 case DMAPDATACOMPASS: //byte
11349 {
11350 ret = ((byte)DMaps[ri->dmapsref].compass) * 10000; break;
11351 }
11352 case DMAPDATAPALETTE: //word
11353 {
11354 ret = ((word)DMaps[ri->dmapsref].color) * 10000; break;
11355 }
11356 case DMAPSCRIPT: //word
11357 {
11358 16 ret = (DMaps[ri->dmapsref].script) * 10000; break;
11359 }
11360 case DMAPDATAMIDI: //byte
11361 {
11362 ret = (DMaps[ri->dmapsref].midi-MIDIOFFSET_DMAP) * 10000; break;
11363 }
11364 case DMAPDATACONTINUE: //byte
11365 {
11366 ret = ((byte)DMaps[ri->dmapsref].cont) * 10000; break;
11367 }
11368 case DMAPDATATYPE: //byte
11369 {
11370 ret = ((byte)DMaps[ri->dmapsref].type&dmfTYPE) * 10000; break;
11371 }
11372 case DMAPDATASIDEVIEW: //byte
11373 {
11374 734834 ret = ((DMaps[ri->dmapsref].sideview) ? 10000 : 0); break;
11375 }
11376 case DMAPDATAGRID: //byte[8] --array
11377 {
11378 int32_t indx = ri->d[rINDEX] / 10000;
11379 if ( indx < 0 || indx > 7 )
11380 {
11381 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx);
11382 ret = -10000;
11383 break;
11384 }
11385 else
11386 {
11387 ret = ((byte)DMaps[ri->dmapsref].grid[indx]) * 10000; break;
11388 }
11389 }
11390 case DMAPINITD: //byte[8] --array
11391 {
11392 24 int32_t indx = ri->d[rINDEX] / 10000;
11393
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if ( indx < 0 || indx > 7 )
11394 {
11395 Z_scripterrlog("Invalid index supplied to dmapdata->InitD[]: %d\n", indx);
11396 ret = -10000;
11397 break;
11398 }
11399 else
11400 {
11401 24 ret = DMaps[ri->dmapsref].initD[indx]; break;
11402 }
11403 }
11404 case DMAPDATAMINIMAPTILE: //word - two of these, so let's do MinimapTile[2]
11405 {
11406 int32_t indx = ri->d[rINDEX] / 10000;
11407 switch(indx)
11408 {
11409 case 0: { ret = ((word)DMaps[ri->dmapsref].minimap_1_tile) * 10000; break; }
11410 case 1: { ret = ((word)DMaps[ri->dmapsref].minimap_2_tile) * 10000; break; }
11411 default:
11412 {
11413 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapTile[]: %d\n", indx);
11414 ret = -10000;
11415 break;
11416 }
11417 }
11418 break;
11419 }
11420 case DMAPDATAMINIMAPCSET: //byte - two of these, so let's do MinimapCSet[2]
11421 {
11422 int32_t indx = ri->d[rINDEX] / 10000;
11423 switch(indx)
11424 {
11425 case 0: { ret = ((byte)DMaps[ri->dmapsref].minimap_1_cset) * 10000; break; }
11426 case 1: { ret = ((byte)DMaps[ri->dmapsref].minimap_2_cset) * 10000; break; }
11427 default:
11428 {
11429 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapCSet[]: %d\n", indx);
11430 ret = -10000;
11431 break;
11432 }
11433 }
11434 break;
11435 }
11436 case DMAPDATALARGEMAPTILE: //word -- two of these, so let's to LargemapTile[2]
11437 {
11438 int32_t indx = ri->d[rINDEX] / 10000;
11439 switch(indx)
11440 {
11441 case 0: { ret = ((word)DMaps[ri->dmapsref].largemap_1_tile) * 10000; break; }
11442 case 1: { ret = ((word)DMaps[ri->dmapsref].largemap_2_tile) * 10000; break; }
11443 default:
11444 {
11445 Z_scripterrlog("Invalid index supplied to dmapdata->MapTile[]: %d\n", indx);
11446 ret = -10000;
11447 break;
11448 }
11449 }
11450 break;
11451 }
11452 case DMAPDATALARGEMAPCSET: //word -- two of these, so let's to LargemaCSet[2]
11453 {
11454 int32_t indx = ri->d[rINDEX] / 10000;
11455 switch(indx)
11456 {
11457 case 0: { ret = ((byte)DMaps[ri->dmapsref].largemap_1_cset) * 10000; break; }
11458 case 1: { ret = ((byte)DMaps[ri->dmapsref].largemap_2_cset) * 10000; break; }
11459 default:
11460 {
11461 Z_scripterrlog("Invalid index supplied to dmapdata->MapCSet[]: %d\n", indx);
11462 ret = -10000;
11463 break;
11464 }
11465 }
11466 break;
11467 }
11468 case DMAPDATAMUISCTRACK: //byte
11469 {
11470 ret = ((byte)DMaps[ri->dmapsref].tmusictrack) * 10000; break;
11471 }
11472 case DMAPDATASUBSCRA:
11473 {
11474 ret = ((byte)DMaps[ri->dmapsref].active_subscreen) * 10000; break;
11475 }
11476 case DMAPDATASUBSCRP:
11477 {
11478 ret = ((byte)DMaps[ri->dmapsref].passive_subscreen) * 10000; break;
11479 }
11480 case DMAPDATASUBSCRO:
11481 {
11482 ret = ((byte)DMaps[ri->dmapsref].overlay_subscreen) * 10000; break;
11483 }
11484 case DMAPDATADISABLEDITEMS: //byte[MAXITEMS]
11485 {
11486 int32_t indx = ri->d[rINDEX] / 10000;
11487 if ( indx < 0 || indx > (MAXITEMS-1) )
11488 {
11489 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx);
11490 ret = -10000;
11491 break;
11492 }
11493 else
11494 {
11495 ret = ((byte)DMaps[ri->dmapsref].disableditems[indx]) * 10000; break;
11496 }
11497 }
11498 case DMAPDATAFLAGARR: //int32_t
11499 {
11500 int32_t indx = ri->d[rINDEX] / 10000;
11501 if ( ((unsigned)indx) > 31 )
11502 {
11503 Z_scripterrlog("Invalid index supplied to dmapdata->Flags[]: %d\n", indx);
11504 ret = -10000;
11505 break;
11506 }
11507 ret = ((DMaps[ri->dmapsref].flags&(1<<indx)) ? 10000:0);
11508 break;
11509 }
11510 case DMAPDATAFLAGS: //int32_t
11511 {
11512 ret = (DMaps[ri->dmapsref].flags) * 10000; break;
11513 }
11514 case DMAPDATAMIRRDMAP:
11515 {
11516 ret = (DMaps[ri->dmapsref].mirrorDMap) * 10000; break;
11517 }
11518 case DMAPDATALOOPSTART:
11519 {
11520 ret = (DMaps[ri->dmapsref].tmusic_loop_start); break;
11521 }
11522 case DMAPDATALOOPEND:
11523 {
11524 ret = (DMaps[ri->dmapsref].tmusic_loop_end); break;
11525 }
11526 case DMAPDATAXFADEIN:
11527 {
11528 ret = (DMaps[ri->dmapsref].tmusic_xfade_in * 10000); break;
11529 }
11530 case DMAPDATAXFADEOUT:
11531 {
11532 ret = (DMaps[ri->dmapsref].tmusic_xfade_out * 10000); break;
11533 }
11534 case DMAPDATAINTROSTRINGID:
11535 {
11536 ret = (DMaps[ri->dmapsref].intro_string_id * 10000); break;
11537 }
11538 case MUSICUPDATECOND:
11539 {
11540 ret = ((byte)FFCore.music_update_cond) * 10000; break;
11541 }
11542 case MUSICUPDATEFLAGS:
11543 {
11544 int32_t indx = ri->d[rINDEX] / 10000;
11545 if (indx < 0 || indx > 2)
11546 {
11547 Z_scripterrlog("Invalid Index passed to Audio->MusicRefreshFlags[]: %d\n", indx);
11548 }
11549 ret = ((FFCore.music_update_flags >> indx) & 1) ? 10000 : 0; break;
11550 }
11551 case DMAPDATAASUBSCRIPT: //word
11552 {
11553 22016 ret = (DMaps[ri->dmapsref].active_sub_script) * 10000; break;
11554 }
11555 case DMAPDATAMAPSCRIPT: //byte
11556 {
11557 ret = (DMaps[ri->dmapsref].onmap_script) * 10000; break;
11558 }
11559 case DMAPDATAPSUBSCRIPT: //word
11560 {
11561 ret = (DMaps[ri->dmapsref].passive_sub_script) * 10000; break;
11562 }
11563 case DMAPDATASUBINITD: //byte[8] --array
11564 {
11565 int32_t indx = ri->d[rINDEX] / 10000;
11566 if ( indx < 0 || indx > 7 )
11567 {
11568 Z_scripterrlog("Invalid index supplied to dmapdata->SubInitD[]: %d\n", indx);
11569 ret = -10000;
11570 break;
11571 }
11572 else
11573 {
11574 ret = DMaps[ri->dmapsref].sub_initD[indx]; break;
11575 }
11576 }
11577
11578 case DMAPDATAMAPINITD: //byte[8] --array
11579 {
11580 int32_t indx = ri->d[rINDEX] / 10000;
11581 if ( indx < 0 || indx > 7 )
11582 {
11583 Z_scripterrlog("Invalid index supplied to dmapdata->MapInitD[]: %d\n", indx);
11584 ret = -10000;
11585 break;
11586 }
11587 else
11588 {
11589 ret = DMaps[ri->dmapsref].onmap_initD[indx]; break;
11590 }
11591 }
11592
11593 case DMAPDATACHARTED:
11594 {
11595 int32_t scr = ri->d[rINDEX] / 10000;
11596 ret = -10000;
11597 if(ri->dmapsref >= MAXDMAPS)
11598 {
11599 Z_scripterrlog("Invalid DMap reference used for dmapdata->Charted[]: %d\n", ri->dmapsref);
11600 }
11601 // else if((DMaps[get_currdmap()].type&dmfTYPE) == dmOVERW)
11602 // {
11603 // Z_scripterrlog("dmapdata->Charted[] cannot presently be used on Overworld-type dmaps\n");
11604 // }
11605 else if(((unsigned)(scr)) > 127)
11606 {
11607 Z_scripterrlog("Invalid index supplied to dmapdata->Charted[]: %d\n", scr);
11608 }
11609 else
11610 {
11611 int32_t col = (scr&15)-(DMaps[ri->dmapsref].type==dmOVERW ? 0 : DMaps[ri->dmapsref].xoff);
11612 if((DMaps[ri->dmapsref].type&dmfTYPE)!=dmOVERW ? (((unsigned)col) > 7) : (((unsigned)col) > 15))
11613 break; //Out-of-bounds; don't attempt read!
11614 int32_t di = (ri->dmapsref << 7) + (scr & 0x7F);
11615 ret = 10000 * game->bmaps[di];
11616 }
11617 break;
11618 }
11619 //case DMAPDATAGRAVITY: //unimplemented
11620 //case DMAPDATAJUMPLAYER: //unimplemented
11621
11622 ///----------------------------------------------------------------------------------------------------//
11623 //messagedata msgd-> variables
11624 case MESSAGEDATANEXT: //W
11625 {
11626 int32_t ID = ri->zmsgref;
11627
11628 if(BC::checkMessage(ID, "messagedata->Next") != SH::_NoError)
11629 {
11630 ret = -10000; break;
11631 }
11632 else
11633 {
11634 ret = ((int32_t)MsgStrings[ID].nextstring) * 10000;
11635 break;
11636 }
11637 }
11638
11639 case MESSAGEDATATILE: //W
11640 {
11641 int32_t ID = ri->zmsgref;
11642
11643 if(BC::checkMessage(ID, "messagedata->Tile") != SH::_NoError)
11644 ret = -10000;
11645 else
11646 ret = ((int32_t)MsgStrings[ID].tile) * 10000;
11647 break;
11648 }
11649
11650 case MESSAGEDATACSET: //b
11651 {
11652 int32_t ID = ri->zmsgref;
11653
11654 if(BC::checkMessage(ID, "messagedata->CSet") != SH::_NoError)
11655 ret = -10000;
11656 else
11657 ret = ((int32_t)MsgStrings[ID].cset) * 10000;
11658 break;
11659 }
11660 case MESSAGEDATATRANS: //BOOL
11661 {
11662 int32_t ID = ri->zmsgref;
11663
11664 if(BC::checkMessage(ID, "messagedata->Transparent") != SH::_NoError)
11665 ret = -10000;
11666 else
11667 ret = ((MsgStrings[ID].trans)?10000:0);
11668 break;
11669 }
11670 case MESSAGEDATAFONT: //B
11671 {
11672 int32_t ID = ri->zmsgref;
11673
11674 if(BC::checkMessage(ID, "messagedata->Font") != SH::_NoError)
11675 ret = -10000;
11676 else
11677 ret = (int32_t)MsgStrings[ID].font * 10000;
11678 break;
11679 }
11680 case MESSAGEDATAX: //SHORT
11681 {
11682 int32_t ID = ri->zmsgref;
11683
11684 if(BC::checkMessage(ID, "messagedata->X") != SH::_NoError)
11685 ret = -10000;
11686 else
11687 ret = ((int32_t)MsgStrings[ID].x) * 10000;
11688 break;
11689 }
11690 case MESSAGEDATAY: //SHORT
11691 {
11692 int32_t ID = ri->zmsgref;
11693
11694 if(BC::checkMessage(ID, "messagedata->Y") != SH::_NoError)
11695 ret = -10000;
11696 else
11697 ret = ((int32_t)MsgStrings[ID].y) * 10000;
11698 break;
11699 }
11700 case MESSAGEDATAW: //UNSIGNED SHORT
11701 {
11702 int32_t ID = ri->zmsgref;
11703
11704 if(BC::checkMessage(ID, "messagedata->Width") != SH::_NoError)
11705 ret = -10000;
11706 else
11707 ret = ((int32_t)MsgStrings[ID].w) * 10000;
11708 break;
11709 }
11710 case MESSAGEDATAH: //UNSIGNED SHORT
11711 {
11712 int32_t ID = ri->zmsgref;
11713
11714 if(BC::checkMessage(ID, "messagedata->Height") != SH::_NoError)
11715 ret = -10000;
11716 else
11717 ret = ((int32_t)MsgStrings[ID].h) * 10000;
11718 break;
11719 }
11720 case MESSAGEDATASFX: //BYTE
11721 {
11722 int32_t ID = ri->zmsgref;
11723
11724 if(BC::checkMessage(ID, "messagedata->Sound") != SH::_NoError)
11725 ret = -10000;
11726 else
11727 ret = ((int32_t)MsgStrings[ID].sfx) * 10000;
11728 break;
11729 }
11730 case MESSAGEDATALISTPOS: //WORD
11731 {
11732 int32_t ID = ri->zmsgref;
11733
11734 if(BC::checkMessage(ID, "messagedata->ListPosition") != SH::_NoError)
11735 ret = -10000;
11736 else
11737 ret = ((int32_t)MsgStrings[ID].listpos) * 10000;
11738 break;
11739 }
11740 case MESSAGEDATAVSPACE: //BYTE
11741 {
11742 int32_t ID = ri->zmsgref;
11743
11744 if(BC::checkMessage(ID, "messagedata->VSpace") != SH::_NoError)
11745 ret = -10000;
11746 else
11747 ret = ((int32_t)MsgStrings[ID].vspace) * 10000;
11748 break;
11749 }
11750 case MESSAGEDATAHSPACE: //BYTE
11751 {
11752 int32_t ID = ri->zmsgref;
11753
11754 if(BC::checkMessage(ID, "messagedata->HSpace") != SH::_NoError)
11755 ret = -10000;
11756 else
11757 ret = ((int32_t)MsgStrings[ID].hspace) * 10000;
11758 break;
11759 }
11760 case MESSAGEDATAFLAGS: //BYTE
11761 {
11762 int32_t ID = ri->zmsgref;
11763
11764 if(BC::checkMessage(ID, "messagedata->Flags") != SH::_NoError)
11765 ret = -10000;
11766 else
11767 ret = ((int32_t)MsgStrings[ID].stringflags) * 10000;
11768 break;
11769 }
11770 case MESSAGEDATAMARGINS: //BYTE, 4
11771 {
11772 int32_t indx = ri->d[rINDEX] / 10000;
11773 if ( indx < 0 || indx > 3 )
11774 {
11775 Z_scripterrlog("Invalid index supplied to messagedata->Margins[]: %d\n", indx);
11776 ret = -10000;
11777 break;
11778 }
11779 int32_t ID = ri->zmsgref;
11780
11781 if(BC::checkMessage(ID, "messagedata->Margins[]") != SH::_NoError)
11782 ret = -10000;
11783 else
11784 ret = ((int32_t)MsgStrings[ID].margins[indx]) * 10000;
11785 break;
11786 }
11787 case MESSAGEDATAPORTTILE: //INT
11788 {
11789 int32_t ID = ri->zmsgref;
11790
11791 if(BC::checkMessage(ID, "messagedata->PortraitTile") != SH::_NoError)
11792 ret = -10000;
11793 else
11794 ret = ((int32_t)MsgStrings[ID].portrait_tile) * 10000;
11795 break;
11796 }
11797 case MESSAGEDATAPORTCSET: //BYTE
11798 {
11799 int32_t ID = ri->zmsgref;
11800
11801 if(BC::checkMessage(ID, "messagedata->PortraitCSet") != SH::_NoError)
11802 ret = -10000;
11803 else
11804 ret = ((int32_t)MsgStrings[ID].portrait_cset) * 10000;
11805 break;
11806 }
11807 case MESSAGEDATAPORTX: //BYTE
11808 {
11809 int32_t ID = ri->zmsgref;
11810
11811 if(BC::checkMessage(ID, "messagedata->PortraitX") != SH::_NoError)
11812 ret = -10000;
11813 else
11814 ret = ((int32_t)MsgStrings[ID].portrait_x) * 10000;
11815 break;
11816 }
11817 case MESSAGEDATAPORTY: //BYTE
11818 {
11819 int32_t ID = ri->zmsgref;
11820
11821 if(BC::checkMessage(ID, "messagedata->PortraitY") != SH::_NoError)
11822 ret = -10000;
11823 else
11824 ret = ((int32_t)MsgStrings[ID].portrait_y) * 10000;
11825 break;
11826 }
11827 case MESSAGEDATAPORTWID: //BYTE
11828 {
11829 int32_t ID = ri->zmsgref;
11830
11831 if(BC::checkMessage(ID, "messagedata->PortraitTileWidth") != SH::_NoError)
11832 ret = -10000;
11833 else
11834 ret = ((int32_t)MsgStrings[ID].portrait_tw) * 10000;
11835 break;
11836 }
11837 case MESSAGEDATAPORTHEI: //BYTE
11838 {
11839 int32_t ID = ri->zmsgref;
11840
11841 if(BC::checkMessage(ID, "messagedata->PortraitTileHeight") != SH::_NoError)
11842 ret = -10000;
11843 else
11844 ret = ((int32_t)MsgStrings[ID].portrait_th) * 10000;
11845 break;
11846 }
11847 case MESSAGEDATATEXTLEN: //BYTE
11848 {
11849 int32_t ID = ri->zmsgref;
11850
11851 if(BC::checkMessage(ID, "messagedata->PortraitTileHeight") != SH::_NoError)
11852 ret = -10000;
11853 else
11854 ret = int32_t(MsgStrings[ID].s.size()) * 10000;
11855 break;
11856 }
11857 case MESSAGEDATATEXTWID:
11858 {
11859 ret = do_msgwidth(ri->zmsgref, "messagedata->TextWidth")*10000;
11860 break;
11861 }
11862 case MESSAGEDATATEXTHEI:
11863 {
11864 ret = do_msgheight(ri->zmsgref, "messagedata->TextHeight")*10000;
11865 break;
11866 }
11867 case MESSAGEDATAFLAGSARR: //BOOL, 7
11868 {
11869 int32_t indx = ri->d[rINDEX] / 10000;
11870 int32_t ID = ri->zmsgref;
11871
11872 if(BC::checkMessage(ID, "messagedata->Flags[]") != SH::_NoError)
11873 ret = -10000;
11874 else
11875 {
11876 switch(indx)
11877 {
11878 case 0:
11879 ret = (MsgStrings[ID].stringflags & STRINGFLAG_WRAP)!=0 ? 10000 : 0;
11880 break;
11881 case 1:
11882 ret = (MsgStrings[ID].stringflags & STRINGFLAG_CONT)!=0 ? 10000 : 0;
11883 break;
11884 case 2: //Not implemented
11885 ret = 0;//ret = (MsgStrings[ID].stringflags & STRINGFLAG_CENTER)!=0 ? 10000 : 0;
11886 break;
11887 case 3: //Not implemented
11888 ret = 0;//ret = (MsgStrings[ID].stringflags & STRINGFLAG_RIGHT)!=0 ? 10000 : 0;
11889 break;
11890 case 4:
11891 ret = (MsgStrings[ID].stringflags & STRINGFLAG_FULLTILE)!=0 ? 10000 : 0;
11892 break;
11893 case 5:
11894 ret = (MsgStrings[ID].stringflags & STRINGFLAG_TRANS_BG)!=0 ? 10000 : 0;
11895 break;
11896 case 6:
11897 ret = (MsgStrings[ID].stringflags & STRINGFLAG_TRANS_FG)!=0 ? 10000 : 0;
11898 break;
11899 default:
11900 Z_scripterrlog("Invalid index supplied to messagedata->Flags[]: %d\n", indx);
11901 ret = -10000;
11902 }
11903 }
11904 break;
11905 }
11906
11907 ///----------------------------------------------------------------------------------------------------//
11908 //combodata cd-> Getter variables
11909 #define GET_COMBO_VAR_INT(member, str) \
11910 { \
11911 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11912 { \
11913 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11914 ret = -10000; \
11915 } \
11916 else \
11917 { \
11918 ret = (combobuf[ri->combosref].member *10000); \
11919 } \
11920 } \
11921
11922 #define GET_COMBO_VAR_BYTE(member, str) \
11923 { \
11924 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11925 { \
11926 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11927 ret = -10000; \
11928 } \
11929 else \
11930 { \
11931 ret = (combobuf[ri->combosref].member *10000); \
11932 } \
11933 } \
11934
11935 #define GET_COMBO_VAR_DWORD(member, str) \
11936 { \
11937 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11938 { \
11939 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11940 ret = -10000; \
11941 } \
11942 else \
11943 { \
11944 ret = (combobuf[ri->combosref].member *10000); \
11945 } \
11946 } \
11947
11948 #define GET_COMBO_VAR_INDEX(member, str, indexbound) \
11949 { \
11950 int32_t indx = ri->d[rINDEX] / 10000; \
11951 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11952 { \
11953 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11954 ret = -10000; \
11955 } \
11956 else if ( indx < 0 || indx >= indexbound ) \
11957 { \
11958 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
11959 ret = -10000; \
11960 } \
11961 else \
11962 { \
11963 ret = (combobuf[ri->combosref].member[indx] * 10000); \
11964 } \
11965 }
11966
11967 #define GET_COMBO_BYTE_INDEX(member, str, indexbound) \
11968 { \
11969 int32_t indx = ri->d[rINDEX] / 10000; \
11970 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11971 { \
11972 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11973 ret = -10000; \
11974 } \
11975 else if ( indx < 0 || indx >= indexbound ) \
11976 { \
11977 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
11978 ret = -10000; \
11979 } \
11980 else \
11981 { \
11982 ret = (combobuf[ri->combosref].member[indx] * 100000); \
11983 } \
11984 }
11985
11986 #define GET_COMBO_FLAG(member, str, indexbound) \
11987 { \
11988 int32_t flag = (value/10000); \
11989 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11990 { \
11991 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11992 } \
11993 else \
11994 { \
11995 ret = (combobuf[ri->combosref].member&flag) ? 10000 : 0); \
11996 } \
11997 } \
11998
11999 //comboclass macros
12000
12001 #define GET_COMBOCLASS_VAR_INT(member, str) \
12002 { \
12003 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
12004 { \
12005 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
12006 ret = -10000; \
12007 } \
12008 else \
12009 { \
12010 ret = (combo_class_buf[combobuf[ri->combosref].type].member *10000); \
12011 } \
12012 } \
12013
12014 #define GET_COMBOCLASS_VAR_BYTE(member, str) \
12015 { \
12016 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
12017 { \
12018 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
12019 ret = -10000; \
12020 } \
12021 else \
12022 { \
12023 ret = (combo_class_buf[combobuf[ri->combosref].type].member *10000); \
12024 } \
12025 } \
12026
12027 #define GET_COMBOCLASS_VAR_DWORD(member, str) \
12028 { \
12029 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
12030 { \
12031 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
12032 ret = -10000; \
12033 } \
12034 else \
12035 { \
12036 ret = (combo_class_buf[combobuf[ri->combosref].type].member *10000); \
12037 } \
12038 } \
12039
12040 #define GET_COMBOCLASS_VAR_INDEX(member, str, indexbound) \
12041 { \
12042 int32_t indx = ri->d[rINDEX] / 10000; \
12043 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
12044 { \
12045 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
12046 ret = -10000; \
12047 } \
12048 else if ( indx < 0 || indx > indexbound ) \
12049 { \
12050 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
12051 ret = -10000; \
12052 } \
12053 else \
12054 { \
12055 ret = (combo_class_buf[combobuf[ri->combosref].type].member[indx] * 10000); \
12056 } \
12057 }
12058
12059 #define GET_COMBOCLASS_BYTE_INDEX(member, str, indexbound) \
12060 { \
12061 int32_t indx = ri->d[rINDEX] / 10000; \
12062 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
12063 { \
12064 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
12065 ret = -10000; \
12066 } \
12067 else if ( indx < 0 || indx > indexbound ) \
12068 { \
12069 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
12070 ret = -10000; \
12071 } \
12072 else \
12073 { \
12074 ret = (combo_class_buf[combobuf[ri->combosref].type].member[indx] * 100000); \
12075 } \
12076 }
12077
12078 #define GET_COMBOCLASS_FLAG(member, str, indexbound) \
12079 { \
12080 int32_t flag = (value/10000); \
12081 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
12082 { \
12083 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
12084 } \
12085 else \
12086 { \
12087 ret = (combo_class_buf[combobuf[ri->combosref].type].member&flag) ? 10000 : 0); \
12088 } \
12089 } \
12090
12091 case COMBOXR:
12092 {
12093 //ri->combosref = id; //'this' pointer
12094 //ri->comboposref = i; //used for X(), Y(), Layer(), and so forth.
12095
1/2
✓ Branch 0 taken 11261 times.
✗ Branch 1 not taken.
11261 if ( curScriptType == ScriptType::Combo )
12096 {
12097 11261 int pos = combopos_ref_to_pos(ri->comboposref);
12098 11261 ret = (( COMBOX(pos) ) * 10000); //comboscriptstack[i]
12099 //this may be wrong...may need a special new var for this, storing the exact combopos
12100 //i is the current script number
12101 11261 }
12102 else
12103 {
12104 Z_scripterrlog("combodata->X() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
12105 ret = -10000;
12106 }
12107 11261 break;
12108 }
12109
12110 case COMBOYR:
12111 {
12112
1/2
✓ Branch 0 taken 11261 times.
✗ Branch 1 not taken.
11261 if ( curScriptType == ScriptType::Combo )
12113 {
12114 11261 int pos = combopos_ref_to_pos(ri->comboposref);
12115 11261 ret = (( COMBOY(pos) ) * 10000); //comboscriptstack[i]
12116 11261 }
12117 else
12118 {
12119 Z_scripterrlog("combodata->Y() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
12120 ret = -10000;
12121 }
12122 11261 break;
12123 }
12124 case COMBOPOSR:
12125 {
12126
1/2
✓ Branch 0 taken 33759 times.
✗ Branch 1 not taken.
33759 if ( curScriptType == ScriptType::Combo )
12127 {
12128 33759 int pos = combopos_ref_to_pos(ri->comboposref);
12129 33759 ret = pos * 10000; //comboscriptstack[i]
12130 33759 }
12131 else
12132 {
12133 Z_scripterrlog("combodata->Pos() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
12134 ret = -10000;
12135 }
12136 33759 break;
12137 }
12138 case COMBOLAYERR:
12139 {
12140
1/2
✓ Branch 0 taken 11044 times.
✗ Branch 1 not taken.
11044 if ( curScriptType == ScriptType::Combo )
12141 {
12142 11044 ret = (( ((ri->comboposref)/176) ) * 10000); //comboscriptstack[i]
12143 11044 }
12144 else
12145 {
12146 Z_scripterrlog("combodata->Pos() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
12147 ret = -10000;
12148 }
12149 11044 break;
12150 }
12151
12152 //NEWCOMBO STRUCT
12153
2/4
✓ Branch 0 taken 4546 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4546 times.
4546 case COMBODTILE: GET_COMBO_VAR_DWORD(tile, "Tile"); break; //word
12154 case COMBODOTILE: GET_COMBO_VAR_DWORD(o_tile, "OriginalTile"); break; //word
12155 case COMBODFRAME: GET_COMBO_VAR_BYTE(cur_frame, "Frame"); break; //char
12156 case COMBODACLK: GET_COMBO_VAR_BYTE(aclk, "AClk"); break; //char
12157 case COMBODASPEED: GET_COMBO_VAR_BYTE(speed, "ASpeed"); break; //char
12158
2/4
✓ Branch 0 taken 4546 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4546 times.
4546 case COMBODFLIP: GET_COMBO_VAR_BYTE(flip, "Flip"); break; //char
12159 case COMBODWALK:
12160 {
12161 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12162 {
12163 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Walk");
12164 ret = -10000;
12165 }
12166 else
12167 {
12168 ret = ((combobuf[ri->combosref].walk&0x0F) *10000);
12169 }
12170 break;
12171 }
12172 case COMBODEFFECT:
12173 {
12174 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12175 {
12176 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Effect");
12177 ret = -10000;
12178 }
12179 else
12180 {
12181 ret = (((combobuf[ri->combosref].walk&0xF0)>>4) *10000);
12182 }
12183 break;
12184 }
12185
2/4
✓ Branch 0 taken 4890 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4890 times.
4890 case COMBODTYPE: GET_COMBO_VAR_BYTE(type, "Type"); break; //char
12186 case COMBODCSET:
12187 {
12188 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12189 {
12190 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2");
12191 ret = -10000;
12192 }
12193 else
12194 {
12195 bool neg = combobuf[ri->combosref].csets&0x8;
12196 ret = ((combobuf[ri->combosref].csets&0x7) * (neg ? -10000 : 10000));
12197 }
12198 break;
12199 }
12200 case COMBODCSET2FLAGS:
12201 {
12202 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12203 {
12204 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2Flags");
12205 }
12206 else
12207 {
12208 ret = ((combobuf[ri->combosref].csets & 0xF0) >> 4) * 10000;
12209 }
12210 break;
12211 }
12212 case COMBODFOO: break; //W
12213
2/4
✓ Branch 0 taken 22172 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 22172 times.
22172 case COMBODATASCRIPT: GET_COMBO_VAR_DWORD(script, "Script"); break; //W
12214 case COMBODFRAMES: GET_COMBO_VAR_BYTE(frames, "Frames"); break; //C
12215 case COMBODNEXTD: GET_COMBO_VAR_DWORD(speed, "NextData"); break; //W
12216 case COMBODNEXTC: GET_COMBO_VAR_BYTE(nextcombo, "NextCSet"); break; //C
12217 case COMBODFLAG: GET_COMBO_VAR_BYTE(nextcset, "Flag"); break; //C
12218 case COMBODSKIPANIM: GET_COMBO_VAR_BYTE(skipanim, "SkipAnim"); break; //C
12219 case COMBODNEXTTIMER: GET_COMBO_VAR_DWORD(nexttimer, "NextTimer"); break; //W
12220 case COMBODAKIMANIMY: GET_COMBO_VAR_BYTE(skipanimy, "SkipAnimY"); break; //C
12221 case COMBODANIMFLAGS: GET_COMBO_VAR_BYTE(animflags, "AnimFlags"); break; //C
12222 case COMBODEXPANSION: GET_COMBO_BYTE_INDEX(expansion, "Expansion[]", 6); break; //C , 6 INDICES
12223 case COMBODATTRIBUTES:
12224 {
12225 66 int32_t indx = ri->d[rINDEX] / 10000;
12226
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
66 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12227 {
12228 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Attributes[]");
12229 ret = -10000;
12230 }
12231
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
66 else if ( indx < 0 || indx > 4 )
12232 {
12233 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "Attributes[]");
12234 ret = -10000;
12235 }
12236 else
12237 {
12238 66 ret = (combobuf[ri->combosref].attributes[indx]);
12239 }
12240 }
12241 66 break;
12242 //case COMBODATAINITD: GET_COMBO_VAR_INDEX(initd, "InitD[]", 2); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
12243 case COMBODATAINITD:
12244 {
12245 1636 int32_t indx = ri->d[rINDEX] / 10000;
12246
2/4
✓ Branch 0 taken 1636 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1636 times.
1636 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12247 {
12248 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "InitD[]");
12249 ret = -10000;
12250 }
12251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
1636 else if ( ((unsigned)indx) > 8 )
12252 {
12253 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "InitD[]");
12254 ret = -10000;
12255 }
12256 else
12257 {
12258 1636 ret = (combobuf[ri->combosref].initd[indx] * (get_qr(qr_COMBODATA_INITD_MULT_TENK) ? 10000 : 1));
12259 }
12260 1636 break;
12261 }
12262
4/8
✓ Branch 0 taken 568 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 568 times.
✓ Branch 4 taken 568 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 568 times.
1136 case COMBODATTRIBYTES: GET_COMBO_VAR_INDEX(attribytes, "Attribytes[]", 8); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
12263
4/8
✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
✓ Branch 4 taken 136 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 136 times.
272 case COMBODATTRISHORTS: GET_COMBO_VAR_INDEX(attrishorts, "Attrishorts[]", 8); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
12264 case COMBODUSRFLAGARR:
12265 {
12266 int32_t indx = ri->d[rINDEX] / 10000;
12267 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
12268 {
12269 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "Flags[]", (ri->combosref * 10000));
12270 ret = 0;
12271 }
12272 else if (((unsigned)indx) > 15)
12273 {
12274 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "Flags[]", indx);
12275 ret = 0;
12276 }
12277 else
12278 {
12279 ret = (combobuf[ri->combosref].usrflags & 1 << indx) ? 10000L : 0L;
12280 }
12281 break;
12282 }
12283 case COMBODGENFLAGARR:
12284 {
12285 int32_t indx = ri->d[rINDEX] / 10000;
12286 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
12287 {
12288 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "GenFlags[]", (ri->combosref * 10000));
12289 ret = 0;
12290 }
12291 else if (((unsigned)indx) > 1)
12292 {
12293 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "GenFlags[]", indx);
12294 ret = 0;
12295 }
12296 else
12297 {
12298 ret = (combobuf[ri->combosref].genflags & (1 << indx)) ? 10000L : 0L;
12299 }
12300 break;
12301 }
12302 case COMBODUSRFLAGS: GET_COMBO_VAR_INT(usrflags, "UserFlags"); break; //LONG
12303 case COMBODTRIGGERFLAGS: GET_COMBO_VAR_INDEX(triggerflags, "TriggerFlags[]", 6); break; //LONG 3 INDICES AS FLAGSETS
12304 case COMBODTRIGGERFLAGS2:
12305 {
12306 int32_t indx = ri->d[rINDEX] / 10000;
12307 ret = -10000;
12308 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12309 {
12310 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TrigFlags[]");
12311 }
12312 else if ( unsigned(indx) >= 32*6 )
12313 {
12314 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TrigFlags[]");
12315 }
12316 else
12317 {
12318 ret = (combobuf[ri->combosref].triggerflags[indx/32] & (1<<indx%32)) ? 10000L : 0L;
12319 }
12320 break;
12321 }
12322 case COMBODTRIGGERBUTTON:
12323 {
12324 int32_t indx = ri->d[rINDEX] / 10000;
12325 ret = -10000;
12326 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12327 {
12328 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerButton[]");
12329 }
12330 else if ( unsigned(indx) >= 8 )
12331 {
12332 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TriggerButton[]");
12333 }
12334 else
12335 {
12336 ret = (combobuf[ri->combosref].triggerbtn & (1<<indx)) ? 10000L : 0L;
12337 }
12338 break;
12339 }
12340 case COMBODTRIGGERITEM:
12341 {
12342 ret = -10000;
12343 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12344 {
12345 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerItem");
12346 }
12347 else ret = (combobuf[ri->combosref].triggeritem) * 10000;
12348 break;
12349 }
12350 case COMBODTRIGGERTIMER:
12351 {
12352 ret = -10000;
12353 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12354 {
12355 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerTimer");
12356 }
12357 else ret = (combobuf[ri->combosref].trigtimer) * 10000;
12358 break;
12359 }
12360 case COMBODTRIGGERSFX:
12361 {
12362 ret = -10000;
12363 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12364 {
12365 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerSFX");
12366 }
12367 else ret = (combobuf[ri->combosref].trigsfx) * 10000;
12368 break;
12369 }
12370 case COMBODTRIGGERCHANGECMB:
12371 {
12372 ret = -10000;
12373 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12374 {
12375 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerChange");
12376 }
12377 else ret = (combobuf[ri->combosref].trigchange) * 10000;
12378 break;
12379 }
12380 case COMBODTRIGGERPROX:
12381 {
12382 ret = -10000;
12383 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12384 {
12385 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerProximity");
12386 }
12387 else ret = (combobuf[ri->combosref].trigprox) * 10000;
12388 break;
12389 }
12390 case COMBODTRIGGERLIGHTBEAM:
12391 {
12392 ret = -10000;
12393 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12394 {
12395 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerLightBeam");
12396 }
12397 else ret = (combobuf[ri->combosref].triglbeam) * 10000;
12398 break;
12399 }
12400 case COMBODTRIGGERCTR:
12401 {
12402 ret = -10000;
12403 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12404 {
12405 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCounter");
12406 }
12407 else ret = (combobuf[ri->combosref].trigctr) * 10000;
12408 break;
12409 }
12410 case COMBODTRIGGERCTRAMNT:
12411 {
12412 ret = -10000;
12413 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12414 {
12415 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCtrAmount");
12416 }
12417 else ret = (combobuf[ri->combosref].trigctramnt) * 10000;
12418 break;
12419 }
12420 case COMBODTRIGGERCOOLDOWN:
12421 {
12422 ret = -10000;
12423 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12424 {
12425 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCooldown: %d\n", (ri->combosref*10000));
12426 }
12427 else ret = (combobuf[ri->combosref].trigcooldown) * 10000;
12428 break;
12429 }
12430 case COMBODTRIGGERCOPYCAT:
12431 {
12432 ret = -10000;
12433 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12434 {
12435 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCopycat: %d\n", (ri->combosref*10000));
12436 }
12437 else ret = (combobuf[ri->combosref].trigcopycat) * 10000;
12438 break;
12439 }
12440 case COMBODTRIGITEMPICKUP:
12441 {
12442 ret = -10000;
12443 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12444 {
12445 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerSpawnItemPickup: %d\n", (ri->combosref*10000));
12446 }
12447 else ret = (combobuf[ri->combosref].spawnip) * 10000;
12448 break;
12449 }
12450 case COMBODTRIGEXSTATE:
12451 {
12452 ret = -10000;
12453 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12454 {
12455 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigExState: %d\n", (ri->combosref*10000));
12456 }
12457 else ret = (combobuf[ri->combosref].exstate) * 10000;
12458 break;
12459 }
12460 case COMBODTRIGSPAWNENEMY:
12461 {
12462 ret = -10000;
12463 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12464 {
12465 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnEnemy: %d\n", (ri->combosref*10000));
12466 }
12467 else ret = (combobuf[ri->combosref].spawnenemy) * 10000;
12468 break;
12469 }
12470 case COMBODTRIGSPAWNITEM:
12471 {
12472 ret = -10000;
12473 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12474 {
12475 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnItem: %d\n", (ri->combosref*10000));
12476 }
12477 else ret = (combobuf[ri->combosref].spawnitem) * 10000;
12478 break;
12479 }
12480 case COMBODTRIGCSETCHANGE:
12481 {
12482 ret = -10000;
12483 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12484 {
12485 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigCSetChange: %d\n", (ri->combosref*10000));
12486 }
12487 else ret = (combobuf[ri->combosref].trigcschange) * 10000;
12488 break;
12489 }
12490 case COMBODLIFTGFXCOMBO:
12491 {
12492 ret = -10000;
12493 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12494 {
12495 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCombo: %d\n", (ri->combosref*10000));
12496 }
12497 else ret = (combobuf[ri->combosref].liftcmb) * 10000;
12498 break;
12499 }
12500 case COMBODLIFTGFXCCSET:
12501 {
12502 ret = -10000;
12503 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12504 {
12505 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCSet: %d\n", (ri->combosref*10000));
12506 }
12507 else ret = (combobuf[ri->combosref].liftcs) * 10000;
12508 break;
12509 }
12510 case COMBODLIFTUNDERCMB:
12511 {
12512 ret = -10000;
12513 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12514 {
12515 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCombo: %d\n", (ri->combosref*10000));
12516 }
12517 else ret = (combobuf[ri->combosref].liftundercmb) * 10000;
12518 break;
12519 }
12520 case COMBODLIFTUNDERCS:
12521 {
12522 ret = -10000;
12523 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12524 {
12525 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCSet: %d\n", (ri->combosref*10000));
12526 }
12527 else ret = (combobuf[ri->combosref].liftundercs) * 10000;
12528 break;
12529 }
12530 case COMBODLIFTDAMAGE:
12531 {
12532 ret = -10000;
12533 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12534 {
12535 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftDamage: %d\n", (ri->combosref*10000));
12536 }
12537 else ret = (combobuf[ri->combosref].liftdmg) * 10000;
12538 break;
12539 }
12540 case COMBODLIFTLEVEL:
12541 {
12542 ret = -10000;
12543 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12544 {
12545 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftLevel: %d\n", (ri->combosref*10000));
12546 }
12547 else ret = (combobuf[ri->combosref].liftlvl) * 10000;
12548 break;
12549 }
12550 case COMBODLIFTITEM:
12551 {
12552 ret = -10000;
12553 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12554 {
12555 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftItem: %d\n", (ri->combosref*10000));
12556 }
12557 else ret = (combobuf[ri->combosref].liftitm) * 10000;
12558 break;
12559 }
12560 case COMBODLIFTFLAGS:
12561 {
12562 ret = -10000;
12563 int32_t indx = ri->d[rINDEX] / 10000;
12564 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12565 {
12566 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftFlags[]: %d\n", (ri->combosref*10000));
12567 break;
12568 }
12569 if ( unsigned(indx) > 7 )
12570 {
12571 Z_scripterrlog("Invalid index supplied to combodata->LiftFlags[]: %d\n", indx);
12572 break;
12573 }
12574 ret = (combobuf[ri->combosref].liftflags & (1<<indx)) ? 10000 : 0;
12575 break;
12576 }
12577 case COMBODLIFTGFXTYPE:
12578 {
12579 ret = -10000;
12580 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12581 {
12582 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXType: %d\n", (ri->combosref*10000));
12583 }
12584 else ret = (combobuf[ri->combosref].liftgfx) * 10000;
12585 break;
12586 }
12587 case COMBODLIFTGFXSPRITE:
12588 {
12589 ret = -10000;
12590 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12591 {
12592 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXSprite: %d\n", (ri->combosref*10000));
12593 }
12594 else ret = (combobuf[ri->combosref].liftsprite) * 10000;
12595 break;
12596 }
12597 case COMBODLIFTSFX:
12598 {
12599 ret = -10000;
12600 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12601 {
12602 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftSFX: %d\n", (ri->combosref*10000));
12603 }
12604 else ret = (combobuf[ri->combosref].liftsfx) * 10000;
12605 break;
12606 }
12607 case COMBODLIFTBREAKSPRITE:
12608 {
12609 ret = -10000;
12610 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12611 {
12612 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSprite: %d\n", (ri->combosref*10000));
12613 }
12614 else ret = (combobuf[ri->combosref].liftbreaksprite) * 10000;
12615 break;
12616 }
12617 case COMBODLIFTBREAKSFX:
12618 {
12619 ret = -10000;
12620 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12621 {
12622 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSFX: %d\n", (ri->combosref*10000));
12623 }
12624 else ret = (combobuf[ri->combosref].liftbreaksfx) * 10000;
12625 break;
12626 }
12627 case COMBODLIFTHEIGHT:
12628 {
12629 ret = -10000;
12630 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12631 {
12632 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftHeight: %d\n", (ri->combosref*10000));
12633 }
12634 else ret = (combobuf[ri->combosref].lifthei) * 10000;
12635 break;
12636 }
12637 case COMBODLIFTTIME:
12638 {
12639 ret = -10000;
12640 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12641 {
12642 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftTime: %d\n", (ri->combosref*10000));
12643 }
12644 else ret = (combobuf[ri->combosref].lifttime) * 10000;
12645 break;
12646 }
12647 case COMBODLIFTWEAPONITEM:
12648 {
12649 ret = -10000;
12650 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12651 {
12652 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftWeaponItem: %d\n", (ri->combosref*10000));
12653 }
12654 else ret = (combobuf[ri->combosref].lift_parent_item) * 10000;
12655 break;
12656 }
12657 case COMBODTRIGGERLSTATE:
12658 {
12659 ret = -10000;
12660 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12661 {
12662 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigLevelState: %d\n", (ri->combosref*10000));
12663 }
12664 else ret = (combobuf[ri->combosref].trig_lstate) * 10000;
12665 break;
12666 }
12667 case COMBODTRIGGERGSTATE:
12668 {
12669 ret = -10000;
12670 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12671 {
12672 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGlobalState: %d\n", (ri->combosref*10000));
12673 }
12674 else ret = (combobuf[ri->combosref].trig_gstate) * 10000;
12675 break;
12676 }
12677 case COMBODTRIGGERGROUP:
12678 {
12679 ret = -10000;
12680 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12681 {
12682 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroup: %d\n", (ri->combosref*10000));
12683 }
12684 else ret = (combobuf[ri->combosref].trig_group) * 10000;
12685 break;
12686 }
12687 case COMBODTRIGGERGROUPVAL:
12688 {
12689 ret = -10000;
12690 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12691 {
12692 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroupVal: %d\n", (ri->combosref*10000));
12693 }
12694 else ret = (combobuf[ri->combosref].trig_group_val) * 10000;
12695 break;
12696 }
12697 case COMBODTRIGGERGTIMER:
12698 {
12699 ret = -10000;
12700 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12701 {
12702 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGStateTimer: %d\n", (ri->combosref*10000));
12703 }
12704 else ret = (combobuf[ri->combosref].trig_statetime) * 10000;
12705 break;
12706 }
12707 case COMBODTRIGGERGENSCRIPT:
12708 {
12709 ret = -10000;
12710 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12711 {
12712 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGenScript: %d\n", (ri->combosref*10000));
12713 }
12714 else ret = (combobuf[ri->combosref].trig_genscr) * 10000;
12715 break;
12716 }
12717
12718 case COMBODTRIGGERLEVEL: GET_COMBO_VAR_INT(triggerlevel, "TriggerLevel"); break; //LONG
12719 10673 case COMBODATAID: ret = (ri->combosref*10000); break;
12720 //COMBOCLASS STRUCT
12721 //case COMBODNAME: //CHAR[64], STRING
12722 case COMBODBLOCKNPC: GET_COMBOCLASS_VAR_BYTE(block_enemies, "BlockNPC"); break; //C
12723 case COMBODBLOCKHOLE: GET_COMBOCLASS_VAR_BYTE(block_hole, "BlockHole"); break; //C
12724 case COMBODBLOCKTRIG: GET_COMBOCLASS_VAR_BYTE(block_trigger, "BlockTrigger"); break; //C
12725 case COMBODBLOCKWEAPON: GET_COMBOCLASS_BYTE_INDEX(block_weapon, "BlockWeapon[]", 32); break; //C, 32 INDICES
12726 case COMBODCONVXSPEED: GET_COMBOCLASS_VAR_DWORD(conveyor_x_speed, "ConveyorSpeedX"); break; //SHORT
12727 case COMBODCONVYSPEED: GET_COMBOCLASS_VAR_DWORD(conveyor_y_speed, "ConveyorSpeedY"); break; //SHORT
12728 case COMBODSPAWNNPC: GET_COMBOCLASS_VAR_DWORD(create_enemy, "SpawnNPC"); break; //W
12729 case COMBODSPAWNNPCWHEN: GET_COMBOCLASS_VAR_BYTE(create_enemy_when, "SpawnNPCWhen"); break; //C
12730 case COMBODSPAWNNPCCHANGE: GET_COMBOCLASS_VAR_INT(create_enemy_change, "SpawnNPCChange"); break; //LONG
12731 case COMBODDIRCHANGETYPE: GET_COMBOCLASS_VAR_BYTE(directional_change_type, "DirChange"); break; //C
12732 case COMBODDISTANCECHANGETILES: GET_COMBOCLASS_VAR_INT(distance_change_tiles, "DistanceChangeTiles"); break; //LONG
12733 case COMBODDIVEITEM: GET_COMBOCLASS_VAR_DWORD(dive_item, "DiveItem"); break; //SHORT
12734 case COMBODDOCK: GET_COMBOCLASS_VAR_BYTE(dock, "Dock"); break; //C
12735 case COMBODFAIRY: GET_COMBOCLASS_VAR_BYTE(fairy, "Fairy"); break; //C
12736 case COMBODFFATTRCHANGE: GET_COMBOCLASS_VAR_BYTE(ff_combo_attr_change, "FFCAttributeChange"); break; //C
12737 case COMBODFOORDECOTILE: GET_COMBOCLASS_VAR_INT(foot_decorations_tile, "DecorationTile"); break; //LONG
12738 case COMBODFOORDECOTYPE: GET_COMBOCLASS_VAR_BYTE(foot_decorations_type, "DecorationType"); break; //C
12739 case COMBODHOOKSHOTPOINT: GET_COMBOCLASS_VAR_BYTE(hookshot_grab_point, "Hookshot"); break; //C
12740 case COMBODLADDERPASS: GET_COMBOCLASS_VAR_BYTE(ladder_pass, "Ladder"); break; //C
12741 case COMBODLOCKBLOCK: GET_COMBOCLASS_VAR_BYTE(lock_block_type, "LockBlock"); break; //C
12742 case COMBODLOCKBLOCKCHANGE: GET_COMBOCLASS_VAR_INT(lock_block_change, "LockBlockChange"); break; //LONG
12743 case COMBODMAGICMIRROR: GET_COMBOCLASS_VAR_BYTE(magic_mirror_type, "Mirror"); break; //C
12744 case COMBODMODHPAMOUNT: GET_COMBOCLASS_VAR_DWORD(modify_hp_amount, "DamageAmount"); break; //SHORT
12745 case COMBODMODHPDELAY: GET_COMBOCLASS_VAR_BYTE(modify_hp_delay, "DamageDelay"); break; //C
12746 case COMBODMODHPTYPE: GET_COMBOCLASS_VAR_BYTE(modify_hp_type, "DamageType"); break; //C
12747 case COMBODNMODMPAMOUNT: GET_COMBOCLASS_VAR_DWORD(modify_mp_amount, "MagicAmount"); break; //SHORT
12748 case COMBODMODMPDELAY: GET_COMBOCLASS_VAR_BYTE(modify_mp_delay, "MagicDelay"); break; //C
12749 case COMBODMODMPTYPE: GET_COMBOCLASS_VAR_BYTE(modify_mp_type, "MagicType"); break; //C
12750 case COMBODNOPUSHBLOCK: GET_COMBOCLASS_VAR_BYTE(no_push_blocks, "NoPushBlocks"); break; //C
12751 case COMBODOVERHEAD: GET_COMBOCLASS_VAR_BYTE(overhead, "Overhead"); break; //C
12752 case COMBODPLACENPC: GET_COMBOCLASS_VAR_BYTE(place_enemy, "PlaceNPC"); break; //C
12753 case COMBODPUSHDIR: GET_COMBOCLASS_VAR_BYTE(push_direction, "PushDir"); break; //C
12754 case COMBODPUSHWAIT: GET_COMBOCLASS_VAR_BYTE(push_wait, "PushDelay"); break; //C
12755 case COMBODPUSHHEAVY: GET_COMBOCLASS_VAR_BYTE(push_weight, "PushHeavy"); break; //C
12756 case COMBODPUSHED: GET_COMBOCLASS_VAR_BYTE(pushed, "Pushed"); break; //C
12757 case COMBODRAFT: GET_COMBOCLASS_VAR_BYTE(raft, "Raft"); break; //C
12758 case COMBODRESETROOM: GET_COMBOCLASS_VAR_BYTE(reset_room, "ResetRoom"); break; //C
12759 case COMBODSAVEPOINTTYPE: GET_COMBOCLASS_VAR_BYTE(save_point_type, "SavePoint"); break; //C
12760 case COMBODSCREENFREEZETYPE: GET_COMBOCLASS_VAR_BYTE(screen_freeze_type, "FreezeScreen"); break; //C
12761 case COMBODSECRETCOMBO: GET_COMBOCLASS_VAR_BYTE(secret_combo, "SecretCombo"); break; //C
12762 case COMBODSINGULAR: GET_COMBOCLASS_VAR_BYTE(singular, "Singular"); break; //C
12763 case COMBODSLOWWALK: GET_COMBOCLASS_VAR_BYTE(slow_movement, "SlowWalk"); break; //C
12764 case COMBODSTATUETYPE: GET_COMBOCLASS_VAR_BYTE(statue_type, "Statue"); break; //C
12765 case COMBODSTEPTYPE: GET_COMBOCLASS_VAR_BYTE(step_type, "Step"); break; //C
12766 case COMBODSTEPCHANGEINTO: GET_COMBOCLASS_VAR_INT(step_change_to, "StepChange"); break; //LONG
12767 case COMBODSTRIKEWEAPONS: GET_COMBOCLASS_BYTE_INDEX(strike_weapons, "Strike[]", 32); break; //BYTE, 32 INDICES.
12768 case COMBODSTRIKEREMNANTS: GET_COMBOCLASS_VAR_INT(strike_remnants, "StrikeRemnants"); break; //LONG
12769 case COMBODSTRIKEREMNANTSTYPE: GET_COMBOCLASS_VAR_BYTE(strike_remnants_type, "StrikeRemnantsType"); break; //C
12770 case COMBODSTRIKECHANGE: GET_COMBOCLASS_VAR_INT(strike_change, "StrikeChange"); break; //LONG
12771 case COMBODSTRIKEITEM: GET_COMBOCLASS_VAR_DWORD(strike_item, "StrikeItem"); break; //SHORT
12772 case COMBODTOUCHITEM: GET_COMBOCLASS_VAR_DWORD(touch_item, "TouchItem"); break; //SHORT
12773 case COMBODTOUCHSTAIRS: GET_COMBOCLASS_VAR_BYTE(touch_stairs, "TouchStairs"); break; //C
12774 case COMBODTRIGGERTYPE: GET_COMBOCLASS_VAR_BYTE(trigger_type, "TriggerType"); break; //C
12775 case COMBODTRIGGERSENS: GET_COMBOCLASS_VAR_BYTE(trigger_sensitive, "TriggerSensitivity"); break; //C
12776 case COMBODWARPTYPE: GET_COMBOCLASS_VAR_BYTE(warp_type, "Warp"); break; //C
12777 case COMBODWARPSENS: GET_COMBOCLASS_VAR_BYTE(warp_sensitive, "WarpSensitivity"); break; //C
12778 case COMBODWARPDIRECT: GET_COMBOCLASS_VAR_BYTE(warp_direct, "WarpDirect"); break; //C
12779 case COMBODWARPLOCATION: GET_COMBOCLASS_VAR_BYTE(warp_location, "WarpLocation"); break; //C
12780 case COMBODWATER: GET_COMBOCLASS_VAR_BYTE(water, "Liquid"); break; //C
12781 case COMBODWHISTLE: GET_COMBOCLASS_VAR_BYTE(whistle, "Whistle"); break; //C
12782 case COMBODWINGAME: GET_COMBOCLASS_VAR_BYTE(win_game, "WinGame"); break; //C
12783 case COMBODBLOCKWPNLEVEL: GET_COMBOCLASS_VAR_BYTE(block_weapon_lvl, "BlockWeaponLevel"); break; //C
12784
12785
12786
12787 ///----------------------------------------------------------------------------------------------------//
12788 //npcdata nd-> variables
12789
12790 //npcdata nd->member variable
12791 #define GET_NPCDATA_VAR_INT32(member, str) \
12792 { \
12793 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12794 { \
12795 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12796 ret = -10000; \
12797 } \
12798 else \
12799 { \
12800 ret = (guysbuf[ri->npcdataref].member *10000); \
12801 } \
12802 } \
12803
12804 #define GET_NPCDATA_VAR_BYTE(member, str) \
12805 { \
12806 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12807 { \
12808 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12809 ret = -10000; \
12810 } \
12811 else \
12812 { \
12813 ret = (guysbuf[ri->npcdataref].member *10000); \
12814 } \
12815 } \
12816
12817 #define GET_NPCDATA_VAR_INT16(member, str) \
12818 { \
12819 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12820 { \
12821 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12822 ret = -10000; \
12823 } \
12824 else \
12825 { \
12826 ret = (guysbuf[ri->npcdataref].member *10000); \
12827 } \
12828 } \
12829
12830 #define GET_NPCDATA_VAR_INDEX(member, str, indexbound) \
12831 { \
12832 int32_t indx = ri->d[rINDEX] / 10000; \
12833 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12834 { \
12835 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12836 ret = -10000; \
12837 } \
12838 else if ( (unsigned)indx > indexbound ) \
12839 { \
12840 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", str, indx); \
12841 ret = -10000; \
12842 } \
12843 else \
12844 { \
12845 ret = (guysbuf[ri->npcdataref].member[indx] * 10000); \
12846 } \
12847 }
12848
12849 #define GET_NPCDATA_BYTE_INDEX(member, str, indexbound) \
12850 { \
12851 int32_t indx = ri->d[rINDEX] / 10000; \
12852 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12853 { \
12854 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12855 ret = -10000; \
12856 } \
12857 else if ( (unsigned)indx > indexbound ) \
12858 { \
12859 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", str, indx); \
12860 ret = -10000; \
12861 } \
12862 else \
12863 { \
12864 ret = (guysbuf[ri->npcdataref].member[indx] * 100000); \
12865 } \
12866 }
12867
12868 #define GET_NPCDATA_FLAG(member, str, indexbound) \
12869 { \
12870 int32_t flag = (value/10000); \
12871 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12872 { \
12873 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12874 } \
12875 else \
12876 { \
12877 ret = (guysbuf[ID].member&flag) ? 10000 : 0); \
12878 } \
12879 } \
12880
12881 case NPCDATATILE: GET_NPCDATA_VAR_BYTE(tile, "Tile"); break;
12882 case NPCDATAWIDTH: GET_NPCDATA_VAR_BYTE(width, "Width"); break;
12883 case NPCDATAHEIGHT: GET_NPCDATA_VAR_BYTE(height, "Height"); break;
12884 case NPCDATAFLAGS: GET_NPCDATA_VAR_INT16(flags, "Flags"); break; //16 b its
12885 case NPCDATAFLAGS2: GET_NPCDATA_VAR_INT16(flags2, "Flags2"); break; //16 bits
12886 case NPCDATASTILE: GET_NPCDATA_VAR_BYTE(s_tile, "STile"); break;
12887 case NPCDATASWIDTH: GET_NPCDATA_VAR_BYTE(s_width, "SWidth"); break;
12888 case NPCDATASHEIGHT: GET_NPCDATA_VAR_BYTE(s_height, "SHeight"); break;
12889 case NPCDATAETILE: GET_NPCDATA_VAR_INT32(e_tile, "ExTile"); break;
12890 case NPCDATAEWIDTH: GET_NPCDATA_VAR_BYTE(e_width, "ExWidth"); break;
12891 case NPCDATAEHEIGHT: GET_NPCDATA_VAR_BYTE(e_height, "ExHeight"); break;
12892 case NPCDATAHP: GET_NPCDATA_VAR_INT16(hp, "HP"); break;
12893 case NPCDATAFAMILY: GET_NPCDATA_VAR_INT16(family, "Family"); break;
12894 case NPCDATACSET: GET_NPCDATA_VAR_INT16(cset, "CSet"); break;
12895 case NPCDATAANIM: GET_NPCDATA_VAR_INT16(anim, "Anim"); break;
12896 case NPCDATAEANIM: GET_NPCDATA_VAR_INT16(e_anim, "ExAnim"); break;
12897 case NPCDATAFRAMERATE: GET_NPCDATA_VAR_INT16(frate, "Framerate"); break;
12898 case NPCDATAEFRAMERATE: GET_NPCDATA_VAR_INT16(e_frate, "ExFramerate"); break;
12899 case NPCDATATOUCHDAMAGE: GET_NPCDATA_VAR_INT16(dp, "TouchDamage"); break;
12900 case NPCDATAWEAPONDAMAGE: GET_NPCDATA_VAR_INT16(wdp, "WeaponDamage"); break;
12901 case NPCDATAWEAPON: GET_NPCDATA_VAR_INT16(weapon, "Weapon"); break;
12902 case NPCDATARANDOM: GET_NPCDATA_VAR_INT16(rate, "Random"); break;
12903 case NPCDATAHALT: GET_NPCDATA_VAR_INT16(hrate, "Haltrate"); break;
12904 case NPCDATASTEP: GET_NPCDATA_VAR_INT16(step, "Step"); break;
12905 case NPCDATAHOMING: GET_NPCDATA_VAR_INT16(homing, "Homing"); break;
12906 case NPCDATAHUNGER: GET_NPCDATA_VAR_INT16(grumble, "Hunger"); break;
12907 case NPCDATADROPSET: GET_NPCDATA_VAR_INT16(item_set, "Dropset"); break;
12908 case NPCDATABGSFX: GET_NPCDATA_VAR_INT16(bgsfx, "BGSFX"); break;
12909 case NPCDATADEATHSFX: GET_NPCDATA_VAR_BYTE(deadsfx, "DeathSFX"); break;
12910 case NPCDATAHITSFX: GET_NPCDATA_VAR_BYTE(hitsfx, "HitSFX"); break;
12911 case NPCDATAXOFS: GET_NPCDATA_VAR_INT32(xofs, "DrawXOffset"); break;
12912 case NPCDATAYOFS: GET_NPCDATA_VAR_INT32(yofs, "DrawYOffset"); break;
12913 case NPCDATAZOFS: GET_NPCDATA_VAR_INT32(zofs, "DrawZOffset"); break;
12914 case NPCDATAHXOFS: GET_NPCDATA_VAR_INT32(hxofs, "HitXOffset"); break;
12915 case NPCDATAHYOFS: GET_NPCDATA_VAR_INT32(hyofs, "HitYOffset"); break;
12916 case NPCDATAHITWIDTH: GET_NPCDATA_VAR_INT32(hxsz, "HitWidth"); break;
12917 case NPCDATAHITHEIGHT: GET_NPCDATA_VAR_INT32(hysz, "HitHeight"); break;
12918 case NPCDATAHITZ: GET_NPCDATA_VAR_INT32(hzsz, "HitZHeight"); break;
12919 case NPCDATASCRIPT: GET_NPCDATA_VAR_INT32(script, "Script"); break;
12920 case NPCDATATILEWIDTH: GET_NPCDATA_VAR_INT32(txsz, "TileWidth"); break;
12921 case NPCDATATILEHEIGHT: GET_NPCDATA_VAR_INT32(tysz, "TileHeight"); break;
12922 case NPCDATAWPNSPRITE: GET_NPCDATA_VAR_INT32(wpnsprite, "WeaponSprite"); break;
12923 case NPCDATAWEAPONSCRIPT: GET_NPCDATA_VAR_INT32(weaponscript, "WeaponScript"); break;
12924 case NPCDATADEFENSE: GET_NPCDATA_VAR_INDEX(defense, "Defense", 42); break;
12925 case NPCDATAINITD: GET_NPCDATA_VAR_INDEX(initD, "InitD", 8); break;
12926 case NPCDATAWEAPONINITD: GET_NPCDATA_VAR_INDEX(weap_initiald, "WeaponInitD", 8); break;
12927 case NPCDATASIZEFLAG: GET_NPCDATA_VAR_INT32(SIZEflags, "SizeFlags"); break;
12928
12929 case NPCDATAFROZENTILE: GET_NPCDATA_VAR_INT32(frozentile, "FrozenTile"); break;
12930 case NPCDATAFROZENCSET: GET_NPCDATA_VAR_INT32(frozencset, "FrozenCSet"); break;
12931
12932
12933 case NPCDATAATTRIBUTE:
12934 {
12935 int32_t indx = ri->d[rINDEX] / 10000;
12936 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12937 {
12938 Z_scripterrlog("Invalid Sprite ID passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
12939 ret = -10000;
12940 }
12941 else if ( indx < 0 || indx > MAX_NPC_ATRIBUTES )
12942 {
12943 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
12944 ret = -10000;
12945 }
12946 else
12947 {
12948 switch(indx)
12949 {
12950 case 0: ret = (guysbuf[ri->npcdataref].misc1 * 10000); break;
12951 case 1: ret = (guysbuf[ri->npcdataref].misc2 * 10000); break;
12952 case 2: ret = (guysbuf[ri->npcdataref].misc3 * 10000); break;
12953 case 3: ret = (guysbuf[ri->npcdataref].misc4 * 10000); break;
12954 case 4: ret = (guysbuf[ri->npcdataref].misc5 * 10000); break;
12955 case 5: ret = (guysbuf[ri->npcdataref].misc6 * 10000); break;
12956 case 6: ret = (guysbuf[ri->npcdataref].misc7 * 10000); break;
12957 case 7: ret = (guysbuf[ri->npcdataref].misc8 * 10000); break;
12958 case 8: ret = (guysbuf[ri->npcdataref].misc9 * 10000); break;
12959 case 9: ret = (guysbuf[ri->npcdataref].misc10 * 10000); break;
12960 case 10: ret = (guysbuf[ri->npcdataref].misc11 * 10000); break;
12961 case 11: ret = (guysbuf[ri->npcdataref].misc12 * 10000); break;
12962 case 12: ret = (guysbuf[ri->npcdataref].misc13 * 10000); break;
12963 case 13: ret = (guysbuf[ri->npcdataref].misc14 * 10000); break;
12964 case 14: ret = (guysbuf[ri->npcdataref].misc15 * 10000); break;
12965 case 15: ret = (guysbuf[ri->npcdataref].misc16 * 10000); break;
12966 case 16: ret = (guysbuf[ri->npcdataref].misc17 * 10000); break;
12967 case 17: ret = (guysbuf[ri->npcdataref].misc18* 10000); break;
12968 case 18: ret = (guysbuf[ri->npcdataref].misc19 * 10000); break;
12969 case 19: ret = (guysbuf[ri->npcdataref].misc20 * 10000); break;
12970 case 20: ret = (guysbuf[ri->npcdataref].misc21 * 10000); break;
12971 case 21: ret = (guysbuf[ri->npcdataref].misc22 * 10000); break;
12972 case 22: ret = (guysbuf[ri->npcdataref].misc23 * 10000); break;
12973 case 23: ret = (guysbuf[ri->npcdataref].misc24 * 10000); break;
12974 case 24: ret = (guysbuf[ri->npcdataref].misc25 * 10000); break;
12975 case 25: ret = (guysbuf[ri->npcdataref].misc26 * 10000); break;
12976 case 26: ret = (guysbuf[ri->npcdataref].misc27 * 10000); break;
12977 case 27: ret = (guysbuf[ri->npcdataref].misc28 * 10000); break;
12978 case 28: ret = (guysbuf[ri->npcdataref].misc29 * 10000); break;
12979 case 29: ret = (guysbuf[ri->npcdataref].misc30 * 10000); break;
12980 case 30: ret = (guysbuf[ri->npcdataref].misc31 * 10000); break;
12981 case 31: ret = (guysbuf[ri->npcdataref].misc32 * 10000); break;
12982
12983
12984
12985 default:
12986 {
12987 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
12988 ret = -10000;
12989 break;
12990 }
12991 }
12992
12993 }
12994 break;
12995 }
12996
12997 case NPCDATABEHAVIOUR:
12998 {
12999 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
13000 {
13001 ret = -10000;
13002 break;
13003 }
13004 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
13005 switch(index)
13006 {
13007 case 0:
13008 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG1)?10000:0; break;
13009 case 1:
13010 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG2)?10000:0; break;
13011 case 2:
13012 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG3)?10000:0; break;
13013 case 3:
13014 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG4)?10000:0; break;
13015 case 4:
13016 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG5)?10000:0; break;
13017 case 5:
13018 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG6)?10000:0; break;
13019 case 6:
13020 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG7)?10000:0; break;
13021 case 7:
13022 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG8)?10000:0; break;
13023 case 8:
13024 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG9)?10000:0; break;
13025 case 9:
13026 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG10)?10000:0; break;
13027 case 10:
13028 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG11)?10000:0; break;
13029 case 11:
13030 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG12)?10000:0; break;
13031 case 12:
13032 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG13)?10000:0; break;
13033 case 13:
13034 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG14)?10000:0; break;
13035 case 14:
13036 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG15)?10000:0; break;
13037 case 15:
13038 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG16)?10000:0; break;
13039
13040
13041 default:
13042 ret = 0; break;
13043 }
13044
13045 break;
13046 }
13047
13048 case NPCDATASHIELD:
13049 {
13050 int32_t indx = ri->d[rINDEX] / 10000;
13051 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
13052 {
13053 Z_scripterrlog("Invalid NPC ID passed to npcdata->Shield[]: %d\n", (ri->npcdataref*10000));
13054 ret = -10000;
13055 break;
13056 }
13057 else
13058 {
13059 switch(indx)
13060 {
13061 case 0:
13062 {
13063 ret = ((guysbuf[ri->npcdataref].flags&inv_front) ? 10000 : 0);
13064 break;
13065 }
13066 case 1:
13067 {
13068 ret = ((guysbuf[ri->npcdataref].flags&inv_left) ? 10000 : 0);
13069 break;
13070 }
13071 case 2:
13072 {
13073 ret = ((guysbuf[ri->npcdataref].flags&inv_right) ? 10000 : 0);
13074 break;
13075 }
13076 case 3:
13077 {
13078 ret = ((guysbuf[ri->npcdataref].flags&inv_back) ? 10000 : 0);
13079 break;
13080 }
13081 case 4:
13082 {
13083 ret = ((guysbuf[ri->npcdataref].flags&guy_bkshield) ? 10000 : 0);
13084 break;
13085 }
13086 default:
13087 {
13088 Z_scripterrlog("Invalid Array Index passed to npcdata->Shield[]: %d\n", indx);
13089 ret = -10000;
13090 break;
13091 }
13092 }
13093 }
13094 }
13095 break;
13096
13097 case NPCDSHADOWSPR:
13098 {
13099 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
13100 {
13101 Z_scripterrlog("Invalid NPC ID passed to npcdata->ShadowSprite: %d\n", (ri->npcdataref*10000));
13102 ret = -10000;
13103 }
13104 else
13105 {
13106 ret = guysbuf[ri->npcdataref].spr_shadow * 10000;
13107 }
13108 break;
13109 }
13110 case NPCDSPAWNSPR:
13111 {
13112 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
13113 {
13114 Z_scripterrlog("Invalid NPC ID passed to npcdata->SpawnSprite: %d\n", (ri->npcdataref*10000));
13115 ret = -10000;
13116 }
13117 else
13118 {
13119 ret = guysbuf[ri->npcdataref].spr_spawn * 10000;
13120 }
13121 break;
13122 }
13123 case NPCDDEATHSPR:
13124 {
13125 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
13126 {
13127 Z_scripterrlog("Invalid NPC ID passed to npcdata->DeathSprite: %d\n", (ri->npcdataref*10000));
13128 ret = -10000;
13129 }
13130 else
13131 {
13132 ret = guysbuf[ri->npcdataref].spr_death * 10000;
13133 }
13134 break;
13135 }
13136
13137 case NPCMATCHINITDLABEL: //Same form as SetScreenD()
13138 //bool npcdata->MatchInitDLabel("label", d)
13139 {
13140
13141 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
13142 {
13143 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), "MatchInitDLabel()");
13144 ret = 0;
13145 break;
13146 }
13147
13148 int32_t arrayptr = get_register(sarg1) / 10000;
13149 int32_t init_d_index = get_register(sarg2) / 10000;
13150
13151 string name;
13152 ArrayH::getString(arrayptr, name, 256); // What's the limit on name length?
13153
13154 bool match = (!( strcmp(name.c_str(), guysbuf[ri->npcdataref].initD_label[init_d_index] )));
13155
13156 ret = ( match ? 10000 : 0 );
13157 break;
13158 }
13159
13160 ///----------------------------------------------------------------------------------------------------//
13161 //Dropset Variables
13162
13163 case DROPSETITEMS:
13164 {
13165 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
13166 {
13167 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
13168 ret = -10000;
13169 break;
13170 }
13171 int32_t indx = ri->d[rINDEX]/10000;
13172 if(indx < 0 || indx > 9)
13173 {
13174 Z_scripterrlog("Invalid index passed to dropdata->Items[]: %d\n", indx);
13175 ret = -10000;
13176 }
13177 else
13178 {
13179 ret = item_drop_sets[ri->dropsetref].item[indx] * 10000;
13180 }
13181 break;
13182 }
13183 case DROPSETCHANCES:
13184 {
13185 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
13186 {
13187 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
13188 ret = -10000;
13189 break;
13190 }
13191 int32_t indx = ri->d[rINDEX]/10000;
13192 if(indx < 0 || indx > 9)
13193 {
13194 Z_scripterrlog("Invalid index passed to dropdata->Chances[]: %d\n", indx);
13195 ret = -10000;
13196 }
13197 else
13198 {
13199 ret = item_drop_sets[ri->dropsetref].chance[indx+1] * 10000; //+1 is because '0' is 'nothing''s chance
13200 }
13201 break;
13202 }
13203 case DROPSETNULLCHANCE:
13204 {
13205 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
13206 {
13207 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
13208 ret = -10000;
13209 break;
13210 }
13211 ret = item_drop_sets[ri->dropsetref].chance[0] * 10000;
13212 break;
13213 }
13214 case DROPSETCHOOSE:
13215 {
13216 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
13217 {
13218 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
13219 ret = -10000;
13220 break;
13221 }
13222 ret = select_dropitem(ri->dropsetref) * 10000;
13223 break;
13224 }
13225
13226 ///----------------------------------------------------------------------------------------------------//
13227 //Audio Variables
13228
13229 case AUDIOVOLUME:
13230 {
13231 int32_t indx = ri->d[rINDEX] / 10000;
13232 switch(indx)
13233 {
13234
13235 case 0: //midi volume
13236 {
13237 ret = FFScript::do_getMIDI_volume() * 10000;
13238 break;
13239 }
13240 case 1: //digi volume
13241 {
13242 ret = FFScript::do_getDIGI_volume() * 10000;
13243 break;
13244 }
13245 case 2: //emh music volume
13246 {
13247 ret = FFScript::do_getMusic_volume() * 10000;
13248 break;
13249 }
13250 case 3: //sfx volume
13251 {
13252 ret = FFScript::do_getSFX_volume() * 10000;
13253 break;
13254 }
13255 default:
13256 {
13257 Z_scripterrlog("Attempted to access an invalid index of Audio->Volume[]", indx);
13258 ret = -10000;
13259 break;
13260 }
13261 }
13262 }
13263 break;
13264
13265 case AUDIOPAN:
13266 {
13267 ret = FFScript::do_getSFX_pan() * 10000;
13268 break;
13269 }
13270
13271 ///----------------------------------------------------------------------------------------------------//
13272 //Graphics->
13273
13274 case NUMDRAWS:
13275 ret = script_drawing_commands.Count() * 10000;
13276 //ret = FFCore.numscriptdraws * 10000; // This isn't updated until end of frame, making it useless!
13277 break;
13278
13279 case MAXDRAWS:
13280 ret = MAX_SCRIPT_DRAWING_COMMANDS * 10000;
13281 break;
13282
13283 case ISBLANKTILE: ret = (FFCore.IsBlankTile(ri->d[rINDEX]/10000) * 10000); break;
13284 case IS8BITTILE: ret = (FFCore.Is8BitTile(ri->d[rINDEX] / 10000) * 10000); break;
13285
13286 case BITMAPWIDTH:
13287 {
13288 //if ( scb.script_created_bitmaps[ri->bitmapref].u_bmp )
13289 //{
13290 // ret = scb.script_created_bitmaps[ri->bitmapref].u_bmp->w * 10000;
13291 //}
13292 //else ret = 0;
13293 ret = scb.script_created_bitmaps[ri->bitmapref-10].width * 10000;
13294 break;
13295 }
13296
13297 case BITMAPHEIGHT:
13298 {
13299 //Z_scripterrlog("BITMAPHEI|GHT ri->BitmapRef is %d\n", ri->bitmapref);
13300 //Z_scripterrlog("ref bitmap height: %d\n", scb.script_created_bitmaps[ri->bitmapref-10].u_bmp->h);
13301 //if ( scb.script_created_bitmaps[ri->bitmapref].u_bmp )
13302 //{
13303 // ret = scb.script_created_bitmaps[ri->bitmapref].u_bmp->h * 10000;
13304 //}
13305 //else ret = 0;
13306 ret = scb.script_created_bitmaps[ri->bitmapref-10].height * 10000;
13307 break;
13308 }
13309 ///----------------------------------------------------------------------------------------------------//
13310 //File->
13311 case FILEPOS:
13312 {
13313 if(user_file* f = checkFile(ri->fileref, "Pos", true))
13314 {
13315 ret = ftell(f->file); //NOT *10000 -V
13316 }
13317 else ret = -10000L;
13318 break;
13319 }
13320 case FILEEOF:
13321 {
13322 if(user_file* f = checkFile(ri->fileref, "EOF", true))
13323 {
13324 ret = feof(f->file) ? 10000L : 0L; //Boolean
13325 }
13326 else ret = -10000L;
13327 break;
13328 }
13329 case FILEERR:
13330 {
13331 if(user_file* f = checkFile(ri->fileref, "Error", true))
13332 {
13333 ret = ferror(f->file) * 10000L;
13334 }
13335 else ret = -10000L;
13336 break;
13337 }
13338
13339 ///----------------------------------------------------------------------------------------------------//
13340 //Directory->
13341 case DIRECTORYSIZE:
13342 {
13343 if(user_dir* dr = checkDir(ri->directoryref, "Size()", true))
13344 {
13345 ret = dr->size() * 10000L;
13346 }
13347 else ret = -10000L;
13348 break;
13349 }
13350
13351 ///----------------------------------------------------------------------------------------------------//
13352 //Stack->
13353 case STACKSIZE:
13354 {
13355 if(user_stack* st = checkStack(ri->stackref, "Size", true))
13356 {
13357 ret = st->size(); //NOT *10000
13358 }
13359 else ret = -10000L;
13360 break;
13361 }
13362 case STACKFULL:
13363 {
13364 if(user_stack* st = checkStack(ri->stackref, "Full", true))
13365 {
13366 ret = st->full() ? 10000L : 0L;
13367 }
13368 else ret = -10000L;
13369 break;
13370 }
13371
13372 ///----------------------------------------------------------------------------------------------------//
13373 //Module->
13374
13375 case MODULEGETINT:
13376 {
13377 int32_t section_pointer = ((ri->d[rINDEX])/10000);
13378 int32_t element_pointer = ((ri->d[rINDEX2])/10000);
13379 string sectionid;
13380 string elementid;
13381
13382 ArrayH::getString(section_pointer, sectionid);
13383 ArrayH::getString(element_pointer, elementid);
13384
13385 ///set config file
13386 if(!fileexists((char*)moduledata.module_name))
13387 {
13388 Z_scripterrlog("I/O Error: No module definitions found when using Module->GetInt()\n");
13389 ret = -10000;
13390 }
13391 else
13392 {
13393 zc_push_config();
13394 zc_config_file(moduledata.module_name);
13395 ret = zc_get_config_basic(sectionid.c_str(), elementid.c_str(), 0)*10000;
13396 //return config file to zc.cfg
13397 zc_pop_config();
13398 }
13399 break;
13400 }
13401
13402 ///----------------------------------------------------------------------------------------------------//
13403 //Misc./Internal
13404 case REFFFC:
13405 15653 ret = ri->ffcref * 10000;
13406 15653 break;
13407
13408 case REFITEM:
13409 158257 ret = ri->itemref;
13410 158257 break;
13411
13412 case REFITEMCLASS:
13413 56823 ret = ri->idata;
13414 56823 break;
13415
13416 case REFLWPN:
13417 1340206 ret = ri->lwpn;
13418 1340206 break;
13419
13420 case REFEWPN:
13421 2886839 ret = ri->ewpn;
13422 2886839 break;
13423
13424 case REFNPC:
13425 15646729 ret = ri->guyref;
13426 15646729 break;
13427
13428 case REFMAPDATA: ret = ri->mapsref; break;
13429 case REFSCREENDATA: ret = ri->screenref; break;
13430 25786 case REFCOMBODATA: ret = ri->combosref; break;
13431 case REFSPRITEDATA: ret = ri->spritesref; break;
13432 case REFBITMAP: ret = ri->bitmapref; break;
13433 case REFNPCCLASS: ret = ri->npcdataref; break;
13434
13435
13436 756919 case REFDMAPDATA: ret = ri->dmapsref; break;
13437 case REFSHOPDATA: ret = ri->shopsref; break;
13438 case REFMSGDATA: ret = ri->zmsgref; break;
13439 case REFUNTYPED: ret = ri->untypedref; break;
13440
13441 case REFDROPS: ret = ri->dropsetref; break;
13442 case REFBOTTLETYPE: ret = ri->bottletyperef; break;
13443 case REFBOTTLESHOP: ret = ri->bottleshopref; break;
13444 427 case REFGENERICDATA: ret = ri->genericdataref; break;
13445 case REFPONDS: ret = ri->pondref; break;
13446 case REFWARPRINGS: ret = ri->warpringref; break;
13447 case REFDOORS: ret = ri->doorsref; break;
13448 case REFUICOLOURS: ret = ri->zcoloursref; break;
13449 case REFRGB: ret = ri->rgbref; break;
13450 case REFPALETTE: ret = ri->paletteref; break;
13451 case REFTUNES: ret = ri->tunesref; break;
13452 case REFPALCYCLE: ret = ri->palcycleref; break;
13453 case REFGAMEDATA: ret = ri->gamedataref; break;
13454 case REFCHEATS: ret = ri->cheatsref; break;
13455 case REFFILE: ret = ri->fileref; break;
13456 case REFDIRECTORY: ret = ri->directoryref; break;
13457 case REFSTACK: ret = ri->stackref; break;
13458 case REFSUBSCREEN: ret = ri->subdataref; break;
13459 case REFSUBSCREENPAGE: ret = ri->subpageref; break;
13460 case REFSUBSCREENWIDG: ret = ri->subwidgref; break;
13461 case REFRNG: ret = ri->rngref; break;
13462 case CLASS_THISKEY: ret = ri->thiskey; break;
13463 case CLASS_THISKEY2: ret = ri->thiskey2; break;
13464 case REFPALDATA: ret = ri->paldataref; break;
13465
13466
13467 case SP:
13468 ret = ri->sp * 10000;
13469 break;
13470
13471 case PC:
13472 ret = ri->pc;
13473 break;
13474
13475 case SWITCHKEY:
13476 ret = ri->switchkey;
13477 break;
13478
13479 case SCRIPTRAM:
13480 case GLOBALRAM:
13481 952310006 ret = ArrayH::getElement(ri->d[rINDEX] / 10000, ri->d[rINDEX2] / 10000);
13482 952310006 break;
13483
13484 case SCRIPTRAMD:
13485 case GLOBALRAMD:
13486 ret = ArrayH::getElement(ri->d[rINDEX] / 10000, 0);
13487 break;
13488
13489 case GDD://Doesn't work like this =(
13490 ret = game->global_d[ri->d[rINDEX] / 10000];
13491 break;
13492
13493 ///----------------------------------------------------------------------------------------------------//
13494
13495 case PALDATACOLOR:
13496 {
13497 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->GetColor()"))
13498 {
13499 int32_t ind = ri->d[rINDEX] / 10000; // get_register(sarg1) / 10000;
13500 if (unsigned(ind) >= PALDATA_NUM_COLORS)
13501 {
13502 Z_scripterrlog("Invalid color index (%d) passed to paldata->GetColor(). Valid indices are 0-255.\n", ind);
13503 ret = -10000;
13504 break;
13505 }
13506
13507 if (get_bit(pd->colors_used, ind))
13508 {
13509 RGB c = pd->colors[ind];
13510
13511 ret = (c.r << 16) | (c.g << 8) | c.b;
13512 }
13513 else
13514 {
13515 //Z_scripterrlog("Color index (%d) returned an invalid color in paldata->GetColor().\n", ind);
13516 ret = -10000;
13517 break;
13518 }
13519 }
13520 break;
13521 }
13522 case PALDATAR:
13523 ret = FFCore.do_paldata_getrgb(0);
13524 break;
13525 case PALDATAG:
13526 ret = FFCore.do_paldata_getrgb(1);
13527 break;
13528 case PALDATAB:
13529 ret = FFCore.do_paldata_getrgb(2);
13530 break;
13531
13532 ///----------------------------------------------------------------------------------------------------//
13533
13534 case GENDATARUNNING:
13535 {
13536 ret = 0;
13537 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Running"))
13538 {
13539 ret = scr->doscript ? 10000L : 0L;
13540 }
13541 break;
13542 }
13543 case GENDATASIZE:
13544 {
13545 ret = 0;
13546 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "DataSize"))
13547 {
13548 ret = scr->dataSize()*10000;
13549 }
13550 break;
13551 }
13552 case GENDATAEXITSTATE:
13553 {
13554 ret = 0;
13555 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ExitState"))
13556 {
13557 size_t indx = ri->d[rINDEX]/10000;
13558 if(indx >= GENSCR_NUMST)
13559 {
13560 Z_scripterrlog("Invalid index passed to genericdata->ExitState[]: %d\n", indx);
13561 break;
13562 }
13563 ret = (scr->exitState & (1<<indx)) ? 10000L : 0;
13564 }
13565 break;
13566 }
13567 case GENDATARELOADSTATE:
13568 {
13569 ret = 0;
13570 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ReloadState"))
13571 {
13572 size_t indx = ri->d[rINDEX]/10000;
13573 if(indx >= GENSCR_NUMST)
13574 {
13575 Z_scripterrlog("Invalid index passed to genericdata->ReloadState[]: %d\n", indx);
13576 break;
13577 }
13578 ret = (scr->reloadState & (1<<indx)) ? 10000L : 0;
13579 }
13580 break;
13581 }
13582 case GENDATAEVENTSTATE:
13583 {
13584 ret = 0;
13585 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "EventListen"))
13586 {
13587 size_t indx = ri->d[rINDEX]/10000;
13588 if(indx >= GENSCR_NUMEVENT)
13589 {
13590 Z_scripterrlog("Invalid index passed to genericdata->EventListen[]: %d\n", indx);
13591 break;
13592 }
13593 ret = (scr->eventstate & (1<<indx)) ? 10000L : 0;
13594 }
13595 break;
13596 }
13597 case GENDATADATA:
13598 {
13599 ret = 0;
13600 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Data[]"))
13601 {
13602 size_t indx = ri->d[rINDEX]/10000;
13603 if(indx >= scr->dataSize())
13604 {
13605 Z_scripterrlog("Invalid index passed to genericdata->Data[]: %d\n", indx);
13606 break;
13607 }
13608 ret = scr->data[indx];
13609 }
13610 break;
13611 }
13612 case GENDATAINITD:
13613 {
13614 ret = 0;
13615 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "InitD[]"))
13616 {
13617 size_t indx = ri->d[rINDEX]/10000;
13618 if(indx >= 8)
13619 {
13620 Z_scripterrlog("Invalid index passed to genericdata->InitD[]: %d\n", indx);
13621 break;
13622 }
13623 ret = scr->initd[indx];
13624 }
13625 break;
13626 }
13627
13628 ///----------------------------------------------------------------------------------------------------//
13629
13630 case PORTALX:
13631 {
13632 ret = -10000;
13633 if(portal* p = checkPortal(ri->portalref, "X"))
13634 ret = p->x.getZLong();
13635 break;
13636 }
13637 case PORTALY:
13638 {
13639 ret = -10000;
13640 if(portal* p = checkPortal(ri->portalref, "Y"))
13641 ret = p->y.getZLong();
13642 break;
13643 }
13644 case PORTALDMAP:
13645 {
13646 ret = -10000;
13647 if(portal* p = checkPortal(ri->portalref, "DMap"))
13648 ret = p->destdmap*10000;
13649 break;
13650 }
13651 case PORTALSCREEN:
13652 {
13653 ret = -10000;
13654 if(portal* p = checkPortal(ri->portalref, "Screen"))
13655 ret = p->destscr*10000;
13656 break;
13657 }
13658 case PORTALACLK:
13659 {
13660 ret = -10000;
13661 if(portal* p = checkPortal(ri->portalref, "AClk"))
13662 ret = p->aclk*10000;
13663 break;
13664 }
13665 case PORTALAFRM:
13666 {
13667 ret = -10000;
13668 if(portal* p = checkPortal(ri->portalref, "AFrame"))
13669 ret = p->aframe*10000;
13670 break;
13671 }
13672 case PORTALOTILE:
13673 {
13674 ret = -10000;
13675 if(portal* p = checkPortal(ri->portalref, "OriginalTile"))
13676 ret = p->o_tile*10000;
13677 break;
13678 }
13679 case PORTALASPD:
13680 {
13681 ret = -10000;
13682 if(portal* p = checkPortal(ri->portalref, "ASpeed"))
13683 ret = p->aspd*10000;
13684 break;
13685 }
13686 case PORTALFRAMES:
13687 {
13688 ret = -10000;
13689 if(portal* p = checkPortal(ri->portalref, "Frames"))
13690 ret = p->frames*10000;
13691 break;
13692 }
13693 case PORTALSAVED:
13694 {
13695 ret = 0;
13696 if(portal* p = checkPortal(ri->portalref, "SavedPortal"))
13697 ret = p->saved_data;
13698 break;
13699 }
13700 case PORTALCLOSEDIS:
13701 {
13702 ret = 0;
13703 if(portal* p = checkPortal(ri->portalref, "CloseDisabled"))
13704 ret = p->prox_active ? 0 : 10000; //Inverted
13705 break;
13706 }
13707 case REFPORTAL:
13708 {
13709 ret = ri->portalref;
13710 break;
13711 }
13712 case REFSAVPORTAL:
13713 {
13714 ret = ri->saveportalref;
13715 break;
13716 }
13717 case PORTALWARPSFX:
13718 {
13719 ret = 0;
13720 if(portal* p = checkPortal(ri->portalref, "WarpSFX"))
13721 ret = p->wsfx ? 0 : 10000;
13722 break;
13723 }
13724 case PORTALWARPVFX:
13725 {
13726 ret = 0;
13727 if(portal* p = checkPortal(ri->portalref, "WarpEffect"))
13728 ret = p->weffect ? 0 : 10000;
13729 break;
13730 }
13731 case SAVEDPORTALX:
13732 {
13733 ret = -10000;
13734 if(savedportal* p = checkSavedPortal(ri->saveportalref, "X"))
13735 ret = p->x;
13736 break;
13737 }
13738 case SAVEDPORTALY:
13739 {
13740 ret = -10000;
13741 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Y"))
13742 ret = p->y;
13743 break;
13744 }
13745 case SAVEDPORTALSRCDMAP:
13746 {
13747 ret = -10000;
13748 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcDMap"))
13749 ret = p->srcdmap * 10000;
13750 break;
13751 }
13752 case SAVEDPORTALDESTDMAP:
13753 {
13754 ret = -10000;
13755 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestDMap"))
13756 ret = p->destdmap * 10000;
13757 break;
13758 }
13759 case SAVEDPORTALSRCSCREEN:
13760 {
13761 ret = -10000;
13762 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcScreen"))
13763 ret = p->srcscr * 10000;
13764 break;
13765 }
13766 case SAVEDPORTALDSTSCREEN:
13767 {
13768 ret = -10000;
13769 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestScreen"))
13770 ret = p->destscr * 10000;
13771 break;
13772 }
13773 case SAVEDPORTALWARPSFX:
13774 {
13775 ret = -10000;
13776 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpSFX"))
13777 ret = p->sfx * 10000;
13778 break;
13779 }
13780 case SAVEDPORTALWARPVFX:
13781 {
13782 ret = -10000;
13783 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpEffect"))
13784 ret = p->warpfx * 10000;
13785 break;
13786 }
13787 case SAVEDPORTALSPRITE:
13788 {
13789 ret = -10000;
13790 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Sprite"))
13791 ret = p->spr * 10000;
13792 break;
13793 }
13794 case SAVEDPORTALPORTAL:
13795 {
13796 ret = 0;
13797 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Portal"))
13798 ret = getPortalFromSaved(p);
13799 break;
13800 }
13801 case PORTALCOUNT:
13802 {
13803 ret = portals.Count()*10000;
13804 break;
13805 }
13806 case SAVEDPORTALCOUNT:
13807 {
13808 ret = game->user_portals.size()*10000;
13809 break;
13810 }
13811
13812 case GAMEASUBOPEN:
13813 {
13814 ret = subscreen_open ? 10000 : 0;
13815 break;
13816 }
13817 case GAMEASUBYOFF:
13818 {
13819 ret = active_sub_yoff*10000;
13820 break;
13821 }
13822 case GAMENUMASUB:
13823 {
13824 ret = subscreens_active.size()*10000;
13825 break;
13826 }
13827 case GAMENUMPSUB:
13828 {
13829 ret = subscreens_passive.size()*10000;
13830 break;
13831 }
13832 case GAMENUMOSUB:
13833 {
13834 ret = subscreens_overlay.size()*10000;
13835 break;
13836 }
13837
13838 ///----------------------------------------------------------------------------------------------------//
13839
13840 case SUBDATACURPG:
13841 {
13842 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "CurPage"))
13843 if(sub->sub_type == sstACTIVE)
13844 ret = 10000*sub->curpage;
13845 break;
13846 }
13847 case SUBDATANUMPG:
13848 {
13849 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "NumPages"))
13850 {
13851 if(sub->sub_type == sstACTIVE)
13852 ret = 10000*sub->pages.size();
13853 else ret = 10000;
13854 }
13855 break;
13856 }
13857 case SUBDATAPAGES:
13858 {
13859 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "Pages[]"))
13860 {
13861 size_t indx = ri->d[rINDEX]/10000;
13862 size_t sz = sub->sub_type == sstACTIVE ? sub->pages.size() : 1;
13863 if(indx >= sz)
13864 {
13865 Z_scripterrlog("Bad index '%d' to array "
13866 "'subscreendata->Pages[]' of size '%d'\n", indx, sz);
13867 }
13868 else
13869 {
13870 auto [sb,ty,_pg,_ind] = from_subref(ri->subdataref);
13871 ret = get_subref(sb,ty,indx,0);
13872 }
13873 }
13874 break;
13875 }
13876 case SUBDATATYPE:
13877 {
13878 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "Type"))
13879 ret = sub->sub_type*10000;
13880 break;
13881 }
13882 case SUBDATAFLAGS:
13883 {
13884 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "Flags[]"))
13885 {
13886 size_t indx = ri->d[rINDEX]/10000;
13887 size_t sz = 0;
13888 switch(sub->sub_type)
13889 {
13890 case sstACTIVE:
13891 sz = 2;
13892 break;
13893 case sstPASSIVE:
13894 sz = 0;
13895 break;
13896 case sstOVERLAY:
13897 sz = 0;
13898 break;
13899 }
13900 if(indx >= sz)
13901 {
13902 Z_scripterrlog("Bad index '%d' to array "
13903 "'subscreendata->Flags[]' of size '%d'\n", indx, sz);
13904 }
13905 else
13906 ret = (sub->flags & (1<<indx)) ? 10000 : 0;
13907 }
13908 break;
13909 }
13910 ///---- ACTIVE SUBSCREENS ONLY
13911 case SUBDATACURSORPOS:
13912 {
13913 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "CursorPos", sstACTIVE))
13914 {
13915 SubscrPage& pg = sub->cur_page();
13916 ret = pg.cursor_pos * 10000;
13917 }
13918 break;
13919 }
13920 case SUBDATASCRIPT:
13921 {
13922 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "Script", sstACTIVE))
13923 ret = sub->script * 10000;
13924 break;
13925 }
13926 case SUBDATAINITD:
13927 {
13928 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "InitD[]", sstACTIVE))
13929 {
13930 size_t indx = ri->d[rINDEX]/10000;
13931 if(indx >= 8)
13932 {
13933 Z_scripterrlog("Bad index '%d' to array "
13934 "'subscreendata->InitD[8]'\n", indx);
13935 }
13936 else
13937 ret = sub->initd[indx];
13938 }
13939 break;
13940 }
13941 case SUBDATABTNLEFT:
13942 {
13943 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "BtnPageLeft[]", sstACTIVE))
13944 {
13945 size_t indx = ri->d[rINDEX]/10000;
13946 if(indx >= 8)
13947 {
13948 Z_scripterrlog("Bad index '%d' to array "
13949 "'subscreendata->BtnPageLeft[8]'\n", indx);
13950 }
13951 else
13952 ret = (sub->btn_left & (1<<indx)) ? 10000 : 0;
13953 }
13954 break;
13955 }
13956 case SUBDATABTNRIGHT:
13957 {
13958 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "BtnPageRight[]", sstACTIVE))
13959 {
13960 size_t indx = ri->d[rINDEX]/10000;
13961 if(indx >= 8)
13962 {
13963 Z_scripterrlog("Bad index '%d' to array "
13964 "'subscreendata->BtnPageRight[8]'\n", indx);
13965 }
13966 else
13967 ret = (sub->btn_right & (1<<indx)) ? 10000 : 0;
13968 }
13969 break;
13970 }
13971 case SUBDATATRANSLEFTTY:
13972 {
13973 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftType", sstACTIVE))
13974 {
13975 auto& trans = sub->trans_left;
13976 ret = trans.type * 10000;
13977 }
13978 break;
13979 }
13980 case SUBDATATRANSLEFTSFX:
13981 {
13982 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftSFX", sstACTIVE))
13983 {
13984 auto& trans = sub->trans_left;
13985 ret = trans.tr_sfx * 10000;
13986 }
13987 break;
13988 }
13989 case SUBDATATRANSLEFTFLAGS:
13990 {
13991 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftFlags[]", sstACTIVE))
13992 {
13993 auto& trans = sub->trans_left;
13994 size_t indx = ri->d[rINDEX]/10000;
13995 if(indx >= SUBSCR_TRANS_NUMFLAGS)
13996 {
13997 Z_scripterrlog("Bad index '%d' to array "
13998 "'subscreendata->TransLeftFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
13999 }
14000 else
14001 ret = (trans.flags & (1<<indx)) ? 10000 : 0;
14002 }
14003 break;
14004 }
14005 case SUBDATATRANSLEFTARGS:
14006 {
14007 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftArgs[]", sstACTIVE))
14008 {
14009 auto& trans = sub->trans_left;
14010 size_t indx = ri->d[rINDEX]/10000;
14011 if(indx >= SUBSCR_TRANSITION_MAXARG)
14012 {
14013 Z_scripterrlog("Bad index '%d' to array "
14014 "'subscreendata->TransLeftArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
14015 }
14016 else
14017 ret = trans.arg[indx]*SubscrTransition::argScale(trans.type,indx);
14018 }
14019 break;
14020 }
14021 case SUBDATATRANSRIGHTTY:
14022 {
14023 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightType", sstACTIVE))
14024 {
14025 auto& trans = sub->trans_right;
14026 ret = trans.type * 10000;
14027 }
14028 break;
14029 }
14030 case SUBDATATRANSRIGHTSFX:
14031 {
14032 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightSFX", sstACTIVE))
14033 {
14034 auto& trans = sub->trans_right;
14035 ret = trans.tr_sfx * 10000;
14036 }
14037 break;
14038 }
14039 case SUBDATATRANSRIGHTFLAGS:
14040 {
14041 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightFlags[]", sstACTIVE))
14042 {
14043 auto& trans = sub->trans_right;
14044 size_t indx = ri->d[rINDEX]/10000;
14045 if(indx >= SUBSCR_TRANS_NUMFLAGS)
14046 {
14047 Z_scripterrlog("Bad index '%d' to array "
14048 "'subscreendata->TransRightFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
14049 }
14050 else
14051 ret = (trans.flags & (1<<indx)) ? 10000 : 0;
14052 }
14053 break;
14054 }
14055 case SUBDATATRANSRIGHTARGS:
14056 {
14057 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightArgs[]", sstACTIVE))
14058 {
14059 auto& trans = sub->trans_right;
14060 size_t indx = ri->d[rINDEX]/10000;
14061 if(indx >= SUBSCR_TRANSITION_MAXARG)
14062 {
14063 Z_scripterrlog("Bad index '%d' to array "
14064 "'subscreendata->TransRightArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
14065 }
14066 else
14067 ret = trans.arg[indx]*SubscrTransition::argScale(trans.type,indx);
14068 }
14069 break;
14070 }
14071 case SUBDATASELECTORDSTX:
14072 {
14073 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestX", sstACTIVE))
14074 ret = sub->selector_setting.x * 10000;
14075 break;
14076 }
14077 case SUBDATASELECTORDSTY:
14078 {
14079 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestY", sstACTIVE))
14080 ret = sub->selector_setting.y * 10000;
14081 break;
14082 }
14083 case SUBDATASELECTORDSTW:
14084 {
14085 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestW", sstACTIVE))
14086 ret = sub->selector_setting.w * 10000;
14087 break;
14088 }
14089 case SUBDATASELECTORDSTH:
14090 {
14091 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestH", sstACTIVE))
14092 ret = sub->selector_setting.h * 10000;
14093 break;
14094 }
14095 case SUBDATASELECTORWID:
14096 {
14097 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestWid", sstACTIVE))
14098 {
14099 size_t indx = ri->d[rINDEX]/10000;
14100 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14101 {
14102 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14103 "SelectorDestWid[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14104 }
14105 else
14106 ret = sub->selector_setting.tileinfo[indx].sw * 10000;
14107 }
14108 break;
14109 }
14110 case SUBDATASELECTORHEI:
14111 {
14112 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestHei", sstACTIVE))
14113 {
14114 size_t indx = ri->d[rINDEX]/10000;
14115 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14116 {
14117 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14118 "SelectorDestHei[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14119 }
14120 else
14121 ret = sub->selector_setting.tileinfo[indx].sh * 10000;
14122 }
14123 break;
14124 }
14125 case SUBDATASELECTORTILE:
14126 {
14127 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorTile", sstACTIVE))
14128 {
14129 size_t indx = ri->d[rINDEX]/10000;
14130 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14131 {
14132 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14133 "SelectorTile[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14134 }
14135 else
14136 ret = sub->selector_setting.tileinfo[indx].tile * 10000;
14137 }
14138 break;
14139 }
14140 case SUBDATASELECTORCSET:
14141 {
14142 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorCSet", sstACTIVE))
14143 {
14144 size_t indx = ri->d[rINDEX]/10000;
14145 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14146 {
14147 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14148 "SelectorCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14149 }
14150 else
14151 {
14152 byte& cs = sub->selector_setting.tileinfo[indx].cset;
14153 ret = (cs&0x0F) * 10000;
14154 }
14155 }
14156 break;
14157 }
14158 case SUBDATASELECTORFLASHCSET:
14159 {
14160 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorFlashCSet", sstACTIVE))
14161 {
14162 size_t indx = ri->d[rINDEX]/10000;
14163 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14164 {
14165 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14166 "SelectorFlashCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14167 }
14168 else
14169 {
14170 byte& cs = sub->selector_setting.tileinfo[indx].cset;
14171 ret = ((cs&0xF0)>>4) * 10000;
14172 }
14173 }
14174 break;
14175 }
14176 case SUBDATASELECTORFRM:
14177 {
14178 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorFrames", sstACTIVE))
14179 {
14180 size_t indx = ri->d[rINDEX]/10000;
14181 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14182 {
14183 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14184 "SelectorFrames[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14185 }
14186 else
14187 ret = sub->selector_setting.tileinfo[indx].frames * 10000;
14188 }
14189 break;
14190 }
14191 case SUBDATASELECTORASPD:
14192 {
14193 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorASpeed", sstACTIVE))
14194 {
14195 size_t indx = ri->d[rINDEX]/10000;
14196 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14197 {
14198 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14199 "SelectorASpeed[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14200 }
14201 else
14202 ret = sub->selector_setting.tileinfo[indx].speed * 10000;
14203 }
14204 break;
14205 }
14206 case SUBDATASELECTORDELAY:
14207 {
14208 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDelay", sstACTIVE))
14209 {
14210 size_t indx = ri->d[rINDEX]/10000;
14211 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14212 {
14213 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14214 "SelectorDelay[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14215 }
14216 else
14217 ret = sub->selector_setting.tileinfo[indx].delay * 10000;
14218 }
14219 break;
14220 }
14221 ///---- CURRENTLY OPEN ACTIVE SUBSCREEN ONLY
14222 case SUBDATATRANSCLK:
14223 {
14224 ret = -10000;
14225 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransClock", sstACTIVE))
14226 {
14227 if(sub != new_subscreen_active)
14228 Z_scripterrlog("'subscreendata->TransClock' is only"
14229 " valid for the current active subscreen!\n");
14230 else if(subscreen_open && subscr_pg_animating)
14231 ret = subscr_pg_clk*10000;
14232 }
14233 break;
14234 }
14235 case SUBDATATRANSTY:
14236 {
14237 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransType", sstACTIVE))
14238 {
14239 auto& trans = subscr_pg_transition;
14240 if(sub != new_subscreen_active)
14241 Z_scripterrlog("'subscreendata->TransType' is only"
14242 " valid for the current active subscreen!\n");
14243 else if(subscreen_open)
14244 ret = trans.type*10000;
14245 }
14246 break;
14247 }
14248 case SUBDATATRANSFLAGS:
14249 {
14250 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransFlags[]", sstACTIVE))
14251 {
14252 auto& trans = subscr_pg_transition;
14253 size_t indx = ri->d[rINDEX]/10000;
14254 if(indx >= SUBSCR_TRANS_NUMFLAGS)
14255 {
14256 Z_scripterrlog("Bad index '%d' to array "
14257 "'subscreendata->TransFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
14258 }
14259 else if(sub != new_subscreen_active)
14260 Z_scripterrlog("'subscreendata->TransType' is only"
14261 " valid for the current active subscreen!\n");
14262 else if(subscreen_open)
14263 ret = (trans.flags & (1<<indx)) ? 10000 : 0;
14264 }
14265 break;
14266 }
14267 case SUBDATATRANSARGS:
14268 {
14269 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransArgs[]", sstACTIVE))
14270 {
14271 auto& trans = subscr_pg_transition;
14272 size_t indx = ri->d[rINDEX]/10000;
14273 if(indx >= SUBSCR_TRANSITION_MAXARG)
14274 {
14275 Z_scripterrlog("Bad index '%d' to array "
14276 "'subscreendata->TransArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
14277 }
14278 else if(sub != new_subscreen_active)
14279 Z_scripterrlog("'subscreendata->TransType' is only"
14280 " valid for the current active subscreen!\n");
14281 else if(subscreen_open)
14282 ret = trans.arg[indx]*SubscrTransition::argScale(trans.type,indx);
14283 }
14284 break;
14285 }
14286 case SUBDATATRANSFROMPG:
14287 {
14288 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransFromPage", sstACTIVE))
14289 {
14290 if(sub != new_subscreen_active)
14291 Z_scripterrlog("'subscreendata->TransFromPage' is only"
14292 " valid for the current active subscreen!\n");
14293 else if(subscreen_open)
14294 ret = subscr_pg_from*10000;
14295 }
14296 break;
14297 }
14298 case SUBDATATRANSTOPG:
14299 {
14300 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransToPage", sstACTIVE))
14301 {
14302 if(sub != new_subscreen_active)
14303 Z_scripterrlog("'subscreendata->TransToPage' is only"
14304 " valid for the current active subscreen!\n");
14305 else if(subscreen_open)
14306 ret = subscr_pg_to*10000;
14307 }
14308 break;
14309 }
14310
14311 ///----------------------------------------------------------------------------------------------------//
14312 case SUBPGINDEX:
14313 {
14314 if(SubscrPage* pg = checkSubPage(ri->subpageref, "Index"))
14315 ret = pg->getIndex() * 10000;
14316 break;
14317 }
14318 case SUBPGNUMWIDG:
14319 {
14320 if(SubscrPage* pg = checkSubPage(ri->subpageref, "NumWidgets"))
14321 ret = pg->size() * 10000;
14322 break;
14323 }
14324 case SUBPGWIDGETS:
14325 {
14326 if(SubscrPage* pg = checkSubPage(ri->subpageref, "Widgets[]"))
14327 {
14328 size_t indx = ri->d[rINDEX]/10000;
14329 size_t sz = pg->size();
14330 if(indx >= sz)
14331 {
14332 Z_scripterrlog("Bad index '%d' to array "
14333 "'subscreenpage->Widgets[]' of size '%d'\n", indx, sz);
14334 }
14335 else
14336 {
14337 auto [sb,ty,pg,_ind] = from_subref(ri->subpageref);
14338 ret = get_subref(sb,ty,pg,indx);
14339 }
14340 }
14341 break;
14342 }
14343 case SUBPGSUBDATA:
14344 {
14345 if(SubscrPage* pg = checkSubPage(ri->subpageref, "SubData"))
14346 {
14347 auto [sub,ty,_pgid,_ind] = from_subref(ri->subpageref);
14348 ret = get_subref(sub,ty,0,0);
14349 }
14350 break;
14351 }
14352 case SUBPGCURSORPOS:
14353 {
14354 if(SubscrPage* pg = checkSubPage(ri->subpageref, "CursorPos"))
14355 ret = pg->cursor_pos * 10000;
14356 break;
14357 }
14358 ///----------------------------------------------------------------------------------------------------//
14359 ///---- ANY WIDGET TYPE
14360 case SUBWIDGTYPE:
14361 {
14362 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Type"))
14363 ret = 10000*widg->getType();
14364 break;
14365 }
14366 case SUBWIDGINDEX:
14367 {
14368 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Index"))
14369 {
14370 auto [_sub,_ty,_pgid,ind] = from_subref(ri->subwidgref);
14371 ret = 10000*ind;
14372 }
14373 break;
14374 }
14375 case SUBWIDGDISPITM:
14376 {
14377 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "DisplayItem"))
14378 {
14379 ret = 10000*widg->getDisplayItem();
14380 }
14381 break;
14382 }
14383 case SUBWIDGEQPITM:
14384 {
14385 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "EquipItem"))
14386 {
14387 ret = 10000*widg->getItemVal();
14388 }
14389 break;
14390 }
14391 case SUBWIDGPAGE:
14392 {
14393 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Page"))
14394 {
14395 auto [sub,ty,pgid,_ind] = from_subref(ri->subwidgref);
14396 ret = get_subref(sub,ty,pgid,0);
14397 }
14398 break;
14399 }
14400 case SUBWIDGPOS:
14401 {
14402 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Pos"))
14403 ret = 10000*widg->pos;
14404 break;
14405 }
14406 case SUBWIDGPOSES:
14407 {
14408 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PosDirs"))
14409 {
14410 size_t indx = ri->d[rINDEX]/10000;
14411 if(indx >= 4)
14412 {
14413 Z_scripterrlog("Bad index '%d' to array "
14414 "'subscreenwidget->PosDirs[%d]'\n", indx, 4);
14415 ret = -10000;
14416 }
14417 else
14418 {
14419 switch(indx)
14420 {
14421 case up:
14422 ret = 10000*widg->pos_up;
14423 break;
14424 case down:
14425 ret = 10000*widg->pos_down;
14426 break;
14427 case left:
14428 ret = 10000*widg->pos_left;
14429 break;
14430 case right:
14431 ret = 10000*widg->pos_right;
14432 break;
14433 }
14434 }
14435 }
14436 break;
14437 }
14438 case SUBWIDGPOSFLAG:
14439 {
14440 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "VisibleFlags"))
14441 {
14442 size_t indx = ri->d[rINDEX]/10000;
14443 if(indx >= sspNUM)
14444 {
14445 Z_scripterrlog("Bad index '%d' to array "
14446 "'subscreenwidget->VisibleFlags[%d]'\n", indx, sspNUM);
14447 }
14448 else ret = (widg->posflags & (1<<indx)) ? 10000 : 0;
14449 }
14450 break;
14451 }
14452 case SUBWIDGX:
14453 {
14454 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "X"))
14455 ret = 10000*widg->x;
14456 break;
14457 }
14458 case SUBWIDGY:
14459 {
14460 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Y"))
14461 ret = 10000*widg->y;
14462 break;
14463 }
14464 case SUBWIDGW:
14465 {
14466 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "W"))
14467 ret = 10000*widg->w;
14468 break;
14469 }
14470 case SUBWIDGH:
14471 {
14472 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "H"))
14473 ret = 10000*widg->h;
14474 break;
14475 }
14476 case SUBWIDG_DISPX:
14477 {
14478 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "X"))
14479 ret = 10000*widg->getX();
14480 break;
14481 }
14482 case SUBWIDG_DISPY:
14483 {
14484 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Y"))
14485 ret = 10000*widg->getY();
14486 break;
14487 }
14488 case SUBWIDG_DISPW:
14489 {
14490 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "W"))
14491 ret = 10000*widg->getW();
14492 break;
14493 }
14494 case SUBWIDG_DISPH:
14495 {
14496 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "H"))
14497 ret = 10000*widg->getH();
14498 break;
14499 }
14500 case SUBWIDGGENFLAG:
14501 {
14502 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GenFlags"))
14503 {
14504 size_t indx = ri->d[rINDEX]/10000;
14505 if(indx >= SUBSCRFLAG_GEN_COUNT)
14506 {
14507 Z_scripterrlog("Bad index '%d' to array "
14508 "'subscreenwidget->GenFlags[%d]'\n", indx, SUBSCRFLAG_GEN_COUNT);
14509 }
14510 else ret = (widg->genflags & (1<<indx)) ? 10000 : 0;
14511 }
14512 break;
14513 }
14514 case SUBWIDGFLAG:
14515 {
14516 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Flags"))
14517 {
14518 size_t indx = ri->d[rINDEX]/10000;
14519 byte sz = widg->numFlags();
14520 if(indx >= sz)
14521 {
14522 Z_scripterrlog("Bad index '%d' to array "
14523 "'subscreenwidget->Flags[%d]'\n", indx, sz);
14524 }
14525 else ret = (widg->flags & (1<<indx)) ? 10000 : 0;
14526 }
14527 break;
14528 }
14529 ///---- ACTIVE SUBSCREENS ONLY
14530 case SUBWIDGSELECTORDSTX:
14531 {
14532 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestX", sstACTIVE))
14533 ret = 10000*widg->selector_override.x;
14534 break;
14535 }
14536 case SUBWIDGSELECTORDSTY:
14537 {
14538 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestY", sstACTIVE))
14539 ret = 10000*widg->selector_override.y;
14540 break;
14541 }
14542 case SUBWIDGSELECTORDSTW:
14543 {
14544 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestW", sstACTIVE))
14545 ret = 10000*widg->selector_override.w;
14546 break;
14547 }
14548 case SUBWIDGSELECTORDSTH:
14549 {
14550 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestH", sstACTIVE))
14551 ret = 10000*widg->selector_override.h;
14552 break;
14553 }
14554 case SUBWIDGSELECTORWID:
14555 {
14556 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestWid", sstACTIVE))
14557 {
14558 size_t indx = ri->d[rINDEX]/10000;
14559 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14560 {
14561 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14562 "SelectorDestWid[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14563 }
14564 else ret = 10000*widg->selector_override.tileinfo[indx].sw;
14565 }
14566 break;
14567 }
14568 case SUBWIDGSELECTORHEI:
14569 {
14570 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestHei", sstACTIVE))
14571 {
14572 size_t indx = ri->d[rINDEX]/10000;
14573 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14574 {
14575 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14576 "SelectorDestHei[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14577 }
14578 else ret = 10000*widg->selector_override.tileinfo[indx].sh;
14579 }
14580 break;
14581 }
14582 case SUBWIDGSELECTORTILE:
14583 {
14584 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorTile", sstACTIVE))
14585 {
14586 size_t indx = ri->d[rINDEX]/10000;
14587 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14588 {
14589 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14590 "SelectorTile[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14591 }
14592 else ret = 10000*widg->selector_override.tileinfo[indx].tile;
14593 }
14594 break;
14595 }
14596 case SUBWIDGSELECTORCSET:
14597 {
14598 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorCSet", sstACTIVE))
14599 {
14600 size_t indx = ri->d[rINDEX]/10000;
14601 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14602 {
14603 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14604 "SelectorCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14605 }
14606 else ret = 10000*(widg->selector_override.tileinfo[indx].cset&0xF);
14607 }
14608 break;
14609 }
14610 case SUBWIDGSELECTORFLASHCSET:
14611 {
14612 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorFlashCSet", sstACTIVE))
14613 {
14614 size_t indx = ri->d[rINDEX]/10000;
14615 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14616 {
14617 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14618 "SelectorFlashCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14619 }
14620 else ret = 10000*((widg->selector_override.tileinfo[indx].cset&0xF0)>>4);
14621 }
14622 break;
14623 }
14624 case SUBWIDGSELECTORFRM:
14625 {
14626 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorFrames", sstACTIVE))
14627 {
14628 size_t indx = ri->d[rINDEX]/10000;
14629 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14630 {
14631 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14632 "SelectorFrames[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14633 }
14634 else ret = 10000*widg->selector_override.tileinfo[indx].frames;
14635 }
14636 break;
14637 }
14638 case SUBWIDGSELECTORASPD:
14639 {
14640 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorASpeed", sstACTIVE))
14641 {
14642 size_t indx = ri->d[rINDEX]/10000;
14643 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14644 {
14645 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14646 "SelectorASpeed[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14647 }
14648 else ret = 10000*widg->selector_override.tileinfo[indx].speed;
14649 }
14650 break;
14651 }
14652 case SUBWIDGSELECTORDELAY:
14653 {
14654 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDelay", sstACTIVE))
14655 {
14656 size_t indx = ri->d[rINDEX]/10000;
14657 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14658 {
14659 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14660 "SelectorDelay[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14661 }
14662 else ret = 10000*widg->selector_override.tileinfo[indx].delay;
14663 }
14664 break;
14665 }
14666
14667 case SUBWIDGPRESSSCRIPT:
14668 {
14669 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PressScript", sstACTIVE))
14670 ret = 10000*widg->generic_script;
14671 break;
14672 }
14673 case SUBWIDGPRESSINITD:
14674 {
14675 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PressInitD[]", sstACTIVE))
14676 {
14677 size_t indx = ri->d[rINDEX]/10000;
14678 if(indx >= 8)
14679 {
14680 Z_scripterrlog("Bad index '%d' to array "
14681 "'subscreenwidget->PressInitD[8]'\n", indx);
14682 }
14683 else ret = widg->generic_initd[indx];
14684 }
14685 break;
14686 }
14687 case SUBWIDGBTNPRESS:
14688 {
14689 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "BtnPressScript[]", sstACTIVE))
14690 {
14691 size_t indx = ri->d[rINDEX]/10000;
14692 if(indx >= 8)
14693 {
14694 Z_scripterrlog("Bad index '%d' to array "
14695 "'subscreenwidget->BtnPressScript[8]'\n", indx);
14696 }
14697 else ret = (widg->gen_script_btns & (1<<indx)) ? 10000 : 0;
14698 }
14699 break;
14700 }
14701 case SUBWIDGBTNPG:
14702 {
14703 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "BtnPageChange[]", sstACTIVE))
14704 {
14705 size_t indx = ri->d[rINDEX]/10000;
14706 if(indx >= 8)
14707 {
14708 Z_scripterrlog("Bad index '%d' to array "
14709 "'subscreenwidget->BtnPageChange[8]'\n", indx);
14710 }
14711 else ret = (widg->pg_btns & (1<<indx)) ? 10000 : 0;
14712 }
14713 break;
14714 }
14715 case SUBWIDGPGMODE:
14716 {
14717 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageMode", sstACTIVE))
14718 ret = 10000*widg->pg_mode;
14719 break;
14720 }
14721 case SUBWIDGPGTARG:
14722 {
14723 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "TargetPage", sstACTIVE))
14724 ret = 10000*widg->pg_targ;
14725 break;
14726 }
14727
14728 case SUBWIDGTRANSPGTY:
14729 {
14730 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransType", sstACTIVE))
14731 {
14732 auto& trans = widg->pg_trans;
14733 ret = 10000*trans.type;
14734 }
14735 break;
14736 }
14737 case SUBWIDGTRANSPGSFX:
14738 {
14739 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransSFX", sstACTIVE))
14740 {
14741 auto& trans = widg->pg_trans;
14742 ret = 10000*trans.tr_sfx;
14743 }
14744 break;
14745 }
14746 case SUBWIDGTRANSPGFLAGS:
14747 {
14748 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransFlags[]", sstACTIVE))
14749 {
14750 auto& trans = widg->pg_trans;
14751 size_t indx = ri->d[rINDEX]/10000;
14752 if(indx >= SUBSCR_TRANS_NUMFLAGS)
14753 {
14754 Z_scripterrlog("Bad index '%d' to array "
14755 "'subscreenwidget->PageTransFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
14756 }
14757 else ret = (trans.flags & (1<<indx)) ? 10000 : 0;
14758 }
14759 break;
14760 }
14761 case SUBWIDGTRANSPGARGS:
14762 {
14763 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransArgs[]", sstACTIVE))
14764 {
14765 auto& trans = widg->pg_trans;
14766 size_t indx = ri->d[rINDEX]/10000;
14767 if(indx >= SUBSCR_TRANSITION_MAXARG)
14768 {
14769 Z_scripterrlog("Bad index '%d' to array "
14770 "'subscreenwidget->PageTransArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
14771 }
14772 else ret = trans.arg[indx]*SubscrTransition::argScale(trans.type,indx);
14773 }
14774 break;
14775 }
14776 ///---- VARYING WIDGET TYPES
14777 case SUBWIDGTY_CSET:
14778 {
14779 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "CSet[]"))
14780 {
14781 size_t indx = ri->d[rINDEX]/10000;
14782 size_t sz = 0;
14783 byte ty = widg->getType();
14784 switch(ty)
14785 {
14786 case widgFRAME:
14787 case widgMCGUFF:
14788 case widgTILEBLOCK:
14789 case widgMINITILE:
14790 sz = 1;
14791 break;
14792 case widgLGAUGE:
14793 case widgMGAUGE:
14794 case widgMISCGAUGE:
14795 sz = 4;
14796 break;
14797 default:
14798 sz = 0;
14799 bad_subwidg_type("CSet[]", false, ty);
14800 ret = -10000;
14801 break;
14802 }
14803 if(!sz) break;
14804 if(indx >= sz)
14805 {
14806 Z_scripterrlog("Bad index '%d' to array "
14807 "'subscreenwidget->CSet[%d]'\n", indx, sz);
14808 break;
14809 }
14810 switch(ty)
14811 {
14812 case widgFRAME:
14813 ret = ((SW_2x2Frame*)widg)->cs.get_cset()*10000;
14814 break;
14815 case widgMCGUFF:
14816 ret = ((SW_McGuffin*)widg)->cs.get_cset()*10000;
14817 break;
14818 case widgTILEBLOCK:
14819 ret = ((SW_TileBlock*)widg)->cs.get_cset()*10000;
14820 break;
14821 case widgMINITILE:
14822 ret = ((SW_MiniTile*)widg)->cs.get_cset()*10000;
14823 break;
14824 case widgLGAUGE:
14825 case widgMGAUGE:
14826 case widgMISCGAUGE:
14827 ret = 10000*((SW_GaugePiece*)widg)->mts[indx].cset;
14828 break;
14829 }
14830 }
14831 break;
14832 }
14833 case SUBWIDGTY_TILE:
14834 {
14835 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Tile"))
14836 {
14837 size_t indx = ri->d[rINDEX]/10000;
14838 size_t sz = 0;
14839 byte ty = widg->getType();
14840 switch(ty)
14841 {
14842 case widgFRAME:
14843 case widgMCGUFF:
14844 case widgTILEBLOCK:
14845 case widgMINITILE:
14846 sz = 1;
14847 break;
14848 case widgLGAUGE:
14849 case widgMGAUGE:
14850 case widgMISCGAUGE:
14851 sz = 4;
14852 break;
14853 default:
14854 sz = 0;
14855 bad_subwidg_type("Tile[]", false, ty);
14856 ret = -10000;
14857 break;
14858 }
14859 if(!sz) break;
14860 if(indx >= sz)
14861 {
14862 Z_scripterrlog("Bad index '%d' to array "
14863 "'subscreenwidget->Tile[%d]'\n", indx, sz);
14864 break;
14865 }
14866 switch(ty)
14867 {
14868 case widgFRAME:
14869 ret = ret = 10000*((SW_2x2Frame*)widg)->tile;
14870 break;
14871 case widgMCGUFF:
14872 ret = 10000*((SW_McGuffin*)widg)->tile;
14873 break;
14874 case widgTILEBLOCK:
14875 ret = 10000*((SW_TileBlock*)widg)->tile;
14876 break;
14877 case widgMINITILE:
14878 ret = 10000*((SW_MiniTile*)widg)->get_int_tile();
14879 break;
14880 case widgLGAUGE:
14881 case widgMGAUGE:
14882 case widgMISCGAUGE:
14883 ret = 10000*((SW_GaugePiece*)widg)->mts[indx].tile();
14884 break;
14885 }
14886 }
14887 break;
14888 }
14889 case SUBWIDGTY_FONT:
14890 {
14891 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Font"))
14892 {
14893 auto ty = widg->getType();
14894 switch(ty)
14895 {
14896 case widgTEXT:
14897 ret = 10000*((SW_Text*)widg)->fontid;
14898 break;
14899 case widgTEXTBOX:
14900 ret = 10000*((SW_TextBox*)widg)->fontid;
14901 break;
14902 case widgSELECTEDTEXT:
14903 ret = 10000*((SW_SelectedText*)widg)->fontid;
14904 break;
14905 case widgTIME:
14906 ret = 10000*((SW_Time*)widg)->fontid;
14907 break;
14908 case widgCOUNTER:
14909 ret = 10000*((SW_Counter*)widg)->fontid;
14910 break;
14911 case widgBTNCOUNTER:
14912 ret = 10000*((SW_BtnCounter*)widg)->fontid;
14913 break;
14914 case widgOLDCTR:
14915 ret = 10000*((SW_Counters*)widg)->fontid;
14916 break;
14917 case widgMMAPTITLE:
14918 ret = 10000*((SW_MMapTitle*)widg)->fontid;
14919 break;
14920 default:
14921 bad_subwidg_type("Font", false, ty);
14922 ret = -10000;
14923 break;
14924 }
14925 }
14926 break;
14927 }
14928 case SUBWIDGTY_ALIGN:
14929 {
14930 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Align"))
14931 {
14932 auto ty = widg->getType();
14933 switch(ty)
14934 {
14935 case widgTEXT:
14936 ret = 10000*((SW_Text*)widg)->align;
14937 break;
14938 case widgTEXTBOX:
14939 ret = 10000*((SW_TextBox*)widg)->align;
14940 break;
14941 case widgSELECTEDTEXT:
14942 ret = 10000*((SW_SelectedText*)widg)->align;
14943 break;
14944 case widgTIME:
14945 ret = 10000*((SW_Time*)widg)->align;
14946 break;
14947 case widgCOUNTER:
14948 ret = 10000*((SW_Counter*)widg)->align;
14949 break;
14950 case widgBTNCOUNTER:
14951 ret = 10000*((SW_BtnCounter*)widg)->align;
14952 break;
14953 case widgMMAPTITLE:
14954 ret = 10000*((SW_MMapTitle*)widg)->align;
14955 break;
14956 default:
14957 bad_subwidg_type("Align", false, ty);
14958 ret = -10000;
14959 break;
14960 }
14961 }
14962 break;
14963 }
14964 case SUBWIDGTY_SHADOWTY:
14965 {
14966 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ShadowType"))
14967 {
14968 auto ty = widg->getType();
14969 switch(ty)
14970 {
14971 case widgTEXT:
14972 ret = 10000*((SW_Text*)widg)->shadtype;
14973 break;
14974 case widgTEXTBOX:
14975 ret = 10000*((SW_TextBox*)widg)->shadtype;
14976 break;
14977 case widgSELECTEDTEXT:
14978 ret = 10000*((SW_SelectedText*)widg)->shadtype;
14979 break;
14980 case widgTIME:
14981 ret = 10000*((SW_Time*)widg)->shadtype;
14982 break;
14983 case widgCOUNTER:
14984 ret = 10000*((SW_Counter*)widg)->shadtype;
14985 break;
14986 case widgBTNCOUNTER:
14987 ret = 10000*((SW_BtnCounter*)widg)->shadtype;
14988 break;
14989 case widgOLDCTR:
14990 ret = 10000*((SW_Counters*)widg)->shadtype;
14991 break;
14992 case widgMMAPTITLE:
14993 ret = 10000*((SW_MMapTitle*)widg)->shadtype;
14994 break;
14995 default:
14996 bad_subwidg_type("ShadowType", false, ty);
14997 ret = -10000;
14998 break;
14999 }
15000 }
15001 break;
15002 }
15003 case SUBWIDGTY_COLOR_TXT:
15004 {
15005 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorText"))
15006 {
15007 auto ty = widg->getType();
15008 switch(ty)
15009 {
15010 case widgTEXT:
15011 ret = 10000*((SW_Text*)widg)->c_text.get_int_color();
15012 break;
15013 case widgTEXTBOX:
15014 ret = 10000*((SW_TextBox*)widg)->c_text.get_int_color();
15015 break;
15016 case widgSELECTEDTEXT:
15017 ret = 10000*((SW_SelectedText*)widg)->c_text.get_int_color();
15018 break;
15019 case widgTIME:
15020 ret = 10000*((SW_Time*)widg)->c_text.get_int_color();
15021 break;
15022 case widgCOUNTER:
15023 ret = 10000*((SW_Counter*)widg)->c_text.get_int_color();
15024 break;
15025 case widgBTNCOUNTER:
15026 ret = 10000*((SW_BtnCounter*)widg)->c_text.get_int_color();
15027 break;
15028 case widgOLDCTR:
15029 ret = 10000*((SW_Counters*)widg)->c_text.get_int_color();
15030 break;
15031 case widgMMAPTITLE:
15032 ret = 10000*((SW_MMapTitle*)widg)->c_text.get_int_color();
15033 break;
15034 case widgMCGUFF_FRAME:
15035 ret = 10000*((SW_TriFrame*)widg)->c_number.get_int_color();
15036 break;
15037 default:
15038 bad_subwidg_type("ColorText", false, ty);
15039 break;
15040 }
15041 }
15042 break;
15043 }
15044 case SUBWIDGTY_COLOR_SHD:
15045 {
15046 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorShadow"))
15047 {
15048 auto ty = widg->getType();
15049 switch(ty)
15050 {
15051 case widgTEXT:
15052 ret = 10000*((SW_Text*)widg)->c_shadow.get_int_color();
15053 break;
15054 case widgTEXTBOX:
15055 ret = 10000*((SW_TextBox*)widg)->c_shadow.get_int_color();
15056 break;
15057 case widgSELECTEDTEXT:
15058 ret = 10000*((SW_SelectedText*)widg)->c_shadow.get_int_color();
15059 break;
15060 case widgTIME:
15061 ret = 10000*((SW_Time*)widg)->c_shadow.get_int_color();
15062 break;
15063 case widgCOUNTER:
15064 ret = 10000*((SW_Counter*)widg)->c_shadow.get_int_color();
15065 break;
15066 case widgBTNCOUNTER:
15067 ret = 10000*((SW_BtnCounter*)widg)->c_shadow.get_int_color();
15068 break;
15069 case widgOLDCTR:
15070 ret = 10000*((SW_Counters*)widg)->c_shadow.get_int_color();
15071 break;
15072 case widgMMAPTITLE:
15073 ret = 10000*((SW_MMapTitle*)widg)->c_shadow.get_int_color();
15074 break;
15075 default:
15076 bad_subwidg_type("ColorShadow", false, ty);
15077 break;
15078 }
15079 }
15080 break;
15081 }
15082 case SUBWIDGTY_COLOR_BG:
15083 {
15084 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorBG"))
15085 {
15086 auto ty = widg->getType();
15087 switch(ty)
15088 {
15089 case widgTEXT:
15090 ret = 10000*((SW_Text*)widg)->c_bg.get_int_color();
15091 break;
15092 case widgTEXTBOX:
15093 ret = 10000*((SW_TextBox*)widg)->c_bg.get_int_color();
15094 break;
15095 case widgSELECTEDTEXT:
15096 ret = 10000*((SW_SelectedText*)widg)->c_bg.get_int_color();
15097 break;
15098 case widgTIME:
15099 ret = 10000*((SW_Time*)widg)->c_bg.get_int_color();
15100 break;
15101 case widgCOUNTER:
15102 ret = 10000*((SW_Counter*)widg)->c_bg.get_int_color();
15103 break;
15104 case widgBTNCOUNTER:
15105 ret = 10000*((SW_BtnCounter*)widg)->c_bg.get_int_color();
15106 break;
15107 case widgOLDCTR:
15108 ret = 10000*((SW_Counters*)widg)->c_bg.get_int_color();
15109 break;
15110 case widgMMAPTITLE:
15111 ret = 10000*((SW_MMapTitle*)widg)->c_bg.get_int_color();
15112 break;
15113 case widgBGCOLOR:
15114 ret = 10000*((SW_Clear*)widg)->c_bg.get_int_color();
15115 break;
15116 default:
15117 bad_subwidg_type("ColorBG", false, ty);
15118 break;
15119 }
15120 }
15121 break;
15122 }
15123 case SUBWIDGTY_COLOR_OLINE:
15124 {
15125 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorOutline"))
15126 {
15127 auto ty = widg->getType();
15128 switch(ty)
15129 {
15130 case widgLINE:
15131 ret = 10000*((SW_Line*)widg)->c_line.get_int_color();
15132 break;
15133 case widgRECT:
15134 ret = 10000*((SW_Rect*)widg)->c_outline.get_int_color();
15135 break;
15136 case widgMCGUFF_FRAME:
15137 ret = 10000*((SW_TriFrame*)widg)->c_outline.get_int_color();
15138 break;
15139 default:
15140 bad_subwidg_type("ColorOutline", false, ty);
15141 break;
15142 }
15143 }
15144 break;
15145 }
15146 case SUBWIDGTY_COLOR_FILL:
15147 {
15148 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorFill"))
15149 {
15150 auto ty = widg->getType();
15151 switch(ty)
15152 {
15153 case widgRECT:
15154 ret = 10000*((SW_Rect*)widg)->c_fill.get_int_color();
15155 break;
15156 default:
15157 bad_subwidg_type("ColorFill", false, ty);
15158 break;
15159 }
15160 }
15161 break;
15162 }
15163 case SUBWIDGTY_BUTTON:
15164 {
15165 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Button"))
15166 {
15167 auto ty = widg->getType();
15168 switch(ty)
15169 {
15170 case widgBTNITM:
15171 ret = 10000*((SW_ButtonItem*)widg)->btn;
15172 break;
15173 case widgBTNCOUNTER:
15174 ret = 10000*((SW_BtnCounter*)widg)->btn;
15175 break;
15176 default:
15177 bad_subwidg_type("Button", false, ty);
15178 ret = -10000;
15179 break;
15180 }
15181 }
15182 break;
15183 }
15184 case SUBWIDGTY_COUNTERS:
15185 {
15186 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Counter[]"))
15187 {
15188 size_t indx = ri->d[rINDEX]/10000;
15189 size_t sz = 0;
15190 byte ty = widg->getType();
15191 switch(ty)
15192 {
15193 case widgCOUNTER:
15194 sz = 3;
15195 break;
15196 case widgMISCGAUGE:
15197 sz = 1;
15198 break;
15199 default:
15200 sz = 0;
15201 bad_subwidg_type("Counter[]", false, ty);
15202 ret = -10000;
15203 break;
15204 }
15205 if(!sz) break;
15206 if(indx >= sz)
15207 {
15208 Z_scripterrlog("Bad index '%d' to array "
15209 "'subscreenwidget->Counter[%d]'\n", indx, sz);
15210 break;
15211 }
15212 switch(ty)
15213 {
15214 case widgCOUNTER:
15215 ret = ((SW_Counter*)widg)->ctrs[indx]*10000;
15216 break;
15217 case widgMISCGAUGE:
15218 ret = ((SW_MiscGaugePiece*)widg)->counter*10000;
15219 break;
15220 }
15221 }
15222 break;
15223 }
15224 case SUBWIDGTY_MINDIG:
15225 {
15226 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "MinDigits"))
15227 {
15228 auto ty = widg->getType();
15229 switch(ty)
15230 {
15231 case widgCOUNTER:
15232 ret = 10000*((SW_Counter*)widg)->mindigits;
15233 break;
15234 case widgBTNCOUNTER:
15235 ret = 10000*((SW_BtnCounter*)widg)->mindigits;
15236 break;
15237 case widgOLDCTR:
15238 ret = 10000*((SW_Counters*)widg)->digits;
15239 break;
15240 default:
15241 bad_subwidg_type("MinDigits", false, ty);
15242 ret = -10000;
15243 break;
15244 }
15245 }
15246 break;
15247 }
15248 case SUBWIDGTY_MAXDIG:
15249 {
15250 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "MaxDigits"))
15251 {
15252 auto ty = widg->getType();
15253 switch(ty)
15254 {
15255 case widgCOUNTER:
15256 ret = 10000*((SW_Counter*)widg)->maxdigits;
15257 break;
15258 case widgBTNCOUNTER:
15259 ret = 10000*((SW_BtnCounter*)widg)->maxdigits;
15260 break;
15261 default:
15262 bad_subwidg_type("MaxDigits", false, ty);
15263 ret = -10000;
15264 break;
15265 }
15266 }
15267 break;
15268 }
15269 case SUBWIDGTY_INFITM:
15270 {
15271 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "InfiniteItem"))
15272 {
15273 auto ty = widg->getType();
15274 switch(ty)
15275 {
15276 case widgCOUNTER:
15277 ret = 10000*((SW_Counter*)widg)->infitm;
15278 break;
15279 case widgOLDCTR:
15280 ret = 10000*((SW_Counters*)widg)->infitm;
15281 break;
15282 case widgLGAUGE:
15283 case widgMGAUGE:
15284 case widgMISCGAUGE:
15285 ret = 10000*((SW_GaugePiece*)widg)->inf_item;
15286 break;
15287 default:
15288 bad_subwidg_type("InfiniteItem", false, ty);
15289 ret = -10000;
15290 break;
15291 }
15292 }
15293 break;
15294 }
15295 case SUBWIDGTY_INFCHAR:
15296 {
15297 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "InfiniteChar"))
15298 {
15299 auto ty = widg->getType();
15300 switch(ty)
15301 {
15302 case widgCOUNTER:
15303 ret = 10000*byte(((SW_Counter*)widg)->infchar);
15304 break;
15305 case widgOLDCTR:
15306 ret = 10000*byte(((SW_Counters*)widg)->infchar);
15307 break;
15308 case widgBTNCOUNTER:
15309 ret = 10000*byte(((SW_BtnCounter*)widg)->infchar);
15310 break;
15311 default:
15312 bad_subwidg_type("InfiniteChar", false, ty);
15313 break;
15314 }
15315 }
15316 break;
15317 }
15318 case SUBWIDGTY_COSTIND:
15319 {
15320 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "CostIndex"))
15321 {
15322 auto ty = widg->getType();
15323 switch(ty)
15324 {
15325 case widgBTNCOUNTER:
15326 ret = 10000*((SW_BtnCounter*)widg)->costind;
15327 break;
15328 default:
15329 bad_subwidg_type("CostIndex", false, ty);
15330 ret = -1;
15331 break;
15332 }
15333 }
15334 break;
15335 }
15336 case SUBWIDGTY_COLOR_PLAYER:
15337 {
15338 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorPlayer"))
15339 {
15340 auto ty = widg->getType();
15341 switch(ty)
15342 {
15343 case widgMMAP:
15344 ret = 10000*((SW_MMap*)widg)->c_plr.get_int_color();
15345 break;
15346 case widgLMAP:
15347 ret = 10000*((SW_LMap*)widg)->c_plr.get_int_color();
15348 break;
15349 default:
15350 bad_subwidg_type("ColorPlayer", false, ty);
15351 break;
15352 }
15353 }
15354 break;
15355 }
15356 case SUBWIDGTY_COLOR_CMPBLNK:
15357 {
15358 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorCompassBlink"))
15359 {
15360 auto ty = widg->getType();
15361 switch(ty)
15362 {
15363 case widgMMAP:
15364 ret = 10000*((SW_MMap*)widg)->c_cmp_blink.get_int_color();
15365 break;
15366 default:
15367 bad_subwidg_type("ColorCompassBlink", false, ty);
15368 break;
15369 }
15370 }
15371 break;
15372 }
15373 case SUBWIDGTY_COLOR_CMPOFF:
15374 {
15375 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorCompassOff"))
15376 {
15377 auto ty = widg->getType();
15378 switch(ty)
15379 {
15380 case widgMMAP:
15381 ret = 10000*((SW_MMap*)widg)->c_cmp_off.get_int_color();
15382 break;
15383 default:
15384 bad_subwidg_type("ColorCompassOff", false, ty);
15385 break;
15386 }
15387 }
15388 break;
15389 }
15390 case SUBWIDGTY_COLOR_ROOM:
15391 {
15392 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorRoom"))
15393 {
15394 auto ty = widg->getType();
15395 switch(ty)
15396 {
15397 case widgLMAP:
15398 ret = 10000*((SW_LMap*)widg)->c_room.get_int_color();
15399 break;
15400 default:
15401 bad_subwidg_type("ColorRoom", false, ty);
15402 break;
15403 }
15404 }
15405 break;
15406 }
15407 case SUBWIDGTY_ITEMCLASS:
15408 {
15409 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ItemClass"))
15410 {
15411 auto ty = widg->getType();
15412 switch(ty)
15413 {
15414 case widgITEMSLOT:
15415 ret = 10000*((SW_ItemSlot*)widg)->iclass;
15416 break;
15417 default:
15418 bad_subwidg_type("ItemClass", false, ty);
15419 break;
15420 }
15421 }
15422 break;
15423 }
15424 case SUBWIDGTY_ITEMID:
15425 {
15426 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ItemID"))
15427 {
15428 auto ty = widg->getType();
15429 switch(ty)
15430 {
15431 case widgITEMSLOT:
15432 ret = 10000*((SW_ItemSlot*)widg)->iid;
15433 break;
15434 default:
15435 bad_subwidg_type("ItemID", false, ty);
15436 break;
15437 }
15438 }
15439 break;
15440 }
15441 case SUBWIDGTY_FRAMETILE:
15442 {
15443 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "FrameTile"))
15444 {
15445 auto ty = widg->getType();
15446 switch(ty)
15447 {
15448 case widgMCGUFF_FRAME:
15449 ret = 10000*((SW_TriFrame*)widg)->frame_tile;
15450 break;
15451 default:
15452 bad_subwidg_type("FrameTile", false, ty);
15453 break;
15454 }
15455 }
15456 break;
15457 }
15458 case SUBWIDGTY_FRAMECSET:
15459 {
15460 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "FrameCSet"))
15461 {
15462 auto ty = widg->getType();
15463 switch(ty)
15464 {
15465 case widgMCGUFF_FRAME:
15466 ret = 10000*((SW_TriFrame*)widg)->frame_cset;
15467 break;
15468 default:
15469 bad_subwidg_type("FrameCSet", false, ty);
15470 break;
15471 }
15472 }
15473 break;
15474 }
15475 case SUBWIDGTY_PIECETILE:
15476 {
15477 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PieceTile"))
15478 {
15479 auto ty = widg->getType();
15480 switch(ty)
15481 {
15482 case widgMCGUFF_FRAME:
15483 ret = 10000*((SW_TriFrame*)widg)->piece_tile;
15484 break;
15485 default:
15486 bad_subwidg_type("PieceTile", false, ty);
15487 break;
15488 }
15489 }
15490 break;
15491 }
15492 case SUBWIDGTY_PIECECSET:
15493 {
15494 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PieceCSet"))
15495 {
15496 auto ty = widg->getType();
15497 switch(ty)
15498 {
15499 case widgMCGUFF_FRAME:
15500 ret = 10000*((SW_TriFrame*)widg)->piece_cset;
15501 break;
15502 default:
15503 bad_subwidg_type("PieceCSet", false, ty);
15504 break;
15505 }
15506 }
15507 break;
15508 }
15509 case SUBWIDGTY_FLIP:
15510 {
15511 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Flip"))
15512 {
15513 auto ty = widg->getType();
15514 switch(ty)
15515 {
15516 case widgMCGUFF:
15517 ret = 10000*((SW_McGuffin*)widg)->flip;
15518 break;
15519 case widgTILEBLOCK:
15520 ret = 10000*((SW_TileBlock*)widg)->flip;
15521 break;
15522 case widgMINITILE:
15523 ret = 10000*((SW_MiniTile*)widg)->flip;
15524 break;
15525 default:
15526 bad_subwidg_type("Flip", false, ty);
15527 break;
15528 }
15529 }
15530 break;
15531 }
15532 case SUBWIDGTY_NUMBER:
15533 {
15534 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Number"))
15535 {
15536 auto ty = widg->getType();
15537 switch(ty)
15538 {
15539 case widgMCGUFF:
15540 ret = 10000*((SW_McGuffin*)widg)->number;
15541 break;
15542 default:
15543 bad_subwidg_type("Number", false, ty);
15544 break;
15545 }
15546 }
15547 break;
15548 }
15549 case SUBWIDGTY_CORNER:
15550 {
15551 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Corner"))
15552 {
15553 size_t indx = ri->d[rINDEX]/10000;
15554 size_t sz = 0;
15555 byte ty = widg->getType();
15556 switch(ty)
15557 {
15558 case widgMINITILE:
15559 sz = 1;
15560 break;
15561 case widgLGAUGE:
15562 case widgMGAUGE:
15563 case widgMISCGAUGE:
15564 sz = 4;
15565 break;
15566 default:
15567 sz = 0;
15568 bad_subwidg_type("Corner[]", false, ty);
15569 ret = -10000;
15570 break;
15571 }
15572 if(!sz) break;
15573 if(indx >= sz)
15574 {
15575 Z_scripterrlog("Bad index '%d' to array "
15576 "'subscreenwidget->Corner[%d]'\n", indx, sz);
15577 break;
15578 }
15579 switch(ty)
15580 {
15581 case widgMINITILE:
15582 ret = 10000*((SW_MiniTile*)widg)->crn;
15583 break;
15584 case widgLGAUGE:
15585 case widgMGAUGE:
15586 case widgMISCGAUGE:
15587 ret = 10000*((SW_GaugePiece*)widg)->mts[indx].crn();
15588 break;
15589 }
15590 }
15591 break;
15592 }
15593 case SUBWIDGTY_FRAMES:
15594 {
15595 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Frames"))
15596 {
15597 auto ty = widg->getType();
15598 switch(ty)
15599 {
15600 case widgLGAUGE:
15601 case widgMGAUGE:
15602 case widgMISCGAUGE:
15603 ret = 10000*((SW_GaugePiece*)widg)->frames;
15604 break;
15605 default:
15606 bad_subwidg_type("Frames", false, ty);
15607 ret = -10000;
15608 break;
15609 }
15610 }
15611 break;
15612 }
15613 case SUBWIDGTY_SPEED:
15614 {
15615 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Speed"))
15616 {
15617 auto ty = widg->getType();
15618 switch(ty)
15619 {
15620 case widgLGAUGE:
15621 case widgMGAUGE:
15622 case widgMISCGAUGE:
15623 ret = 10000*((SW_GaugePiece*)widg)->speed;
15624 break;
15625 default:
15626 bad_subwidg_type("Speed", false, ty);
15627 ret = -10000;
15628 break;
15629 }
15630 }
15631 break;
15632 }
15633 case SUBWIDGTY_DELAY:
15634 {
15635 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Delay"))
15636 {
15637 auto ty = widg->getType();
15638 switch(ty)
15639 {
15640 case widgLGAUGE:
15641 case widgMGAUGE:
15642 case widgMISCGAUGE:
15643 ret = 10000*((SW_GaugePiece*)widg)->delay;
15644 break;
15645 default:
15646 bad_subwidg_type("Delay", false, ty);
15647 ret = -10000;
15648 break;
15649 }
15650 }
15651 break;
15652 }
15653 case SUBWIDGTY_CONTAINER:
15654 {
15655 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Container"))
15656 {
15657 auto ty = widg->getType();
15658 switch(ty)
15659 {
15660 case widgLGAUGE:
15661 case widgMGAUGE:
15662 case widgMISCGAUGE:
15663 ret = 10000*((SW_GaugePiece*)widg)->container;
15664 break;
15665 default:
15666 bad_subwidg_type("Container", false, ty);
15667 ret = -10000;
15668 break;
15669 }
15670 }
15671 break;
15672 }
15673 case SUBWIDGTY_GAUGE_WID:
15674 {
15675 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GaugeWid"))
15676 {
15677 auto ty = widg->getType();
15678 switch(ty)
15679 {
15680 case widgLGAUGE:
15681 case widgMGAUGE:
15682 case widgMISCGAUGE:
15683 ret = 10000*(((SW_GaugePiece*)widg)->gauge_wid+1);
15684 break;
15685 default:
15686 bad_subwidg_type("GaugeWid", false, ty);
15687 ret = -10000;
15688 break;
15689 }
15690 }
15691 break;
15692 }
15693 case SUBWIDGTY_GAUGE_HEI:
15694 {
15695 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GaugeHei"))
15696 {
15697 auto ty = widg->getType();
15698 switch(ty)
15699 {
15700 case widgLGAUGE:
15701 case widgMGAUGE:
15702 case widgMISCGAUGE:
15703 ret = 10000*(((SW_GaugePiece*)widg)->gauge_hei+1);
15704 break;
15705 default:
15706 bad_subwidg_type("GaugeHei", false, ty);
15707 ret = -10000;
15708 break;
15709 }
15710 }
15711 break;
15712 }
15713 case SUBWIDGTY_UNITS:
15714 {
15715 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Units"))
15716 {
15717 auto ty = widg->getType();
15718 switch(ty)
15719 {
15720 case widgLGAUGE:
15721 case widgMGAUGE:
15722 case widgMISCGAUGE:
15723 ret = 10000*(((SW_GaugePiece*)widg)->unit_per_frame+1);
15724 break;
15725 default:
15726 bad_subwidg_type("Units", false, ty);
15727 ret = -10000;
15728 break;
15729 }
15730 }
15731 break;
15732 }
15733 case SUBWIDGTY_HSPACE:
15734 {
15735 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "HSpace"))
15736 {
15737 auto ty = widg->getType();
15738 switch(ty)
15739 {
15740 case widgLGAUGE:
15741 case widgMGAUGE:
15742 case widgMISCGAUGE:
15743 ret = 10000*((SW_GaugePiece*)widg)->hspace;
15744 break;
15745 default:
15746 bad_subwidg_type("HSpace", false, ty);
15747 ret = -10000;
15748 break;
15749 }
15750 }
15751 break;
15752 }
15753 case SUBWIDGTY_VSPACE:
15754 {
15755 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "VSpace"))
15756 {
15757 auto ty = widg->getType();
15758 switch(ty)
15759 {
15760 case widgLGAUGE:
15761 case widgMGAUGE:
15762 case widgMISCGAUGE:
15763 ret = 10000*((SW_GaugePiece*)widg)->vspace;
15764 break;
15765 default:
15766 bad_subwidg_type("VSpace", false, ty);
15767 ret = -10000;
15768 break;
15769 }
15770 }
15771 break;
15772 }
15773 case SUBWIDGTY_GRIDX:
15774 {
15775 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GridX"))
15776 {
15777 auto ty = widg->getType();
15778 switch(ty)
15779 {
15780 case widgLGAUGE:
15781 case widgMGAUGE:
15782 case widgMISCGAUGE:
15783 ret = 10000*((SW_GaugePiece*)widg)->grid_xoff;
15784 break;
15785 default:
15786 bad_subwidg_type("GridX", false, ty);
15787 ret = -10000;
15788 break;
15789 }
15790 }
15791 break;
15792 }
15793 case SUBWIDGTY_GRIDY:
15794 {
15795 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GridY"))
15796 {
15797 auto ty = widg->getType();
15798 switch(ty)
15799 {
15800 case widgLGAUGE:
15801 case widgMGAUGE:
15802 case widgMISCGAUGE:
15803 ret = 10000*((SW_GaugePiece*)widg)->grid_yoff;
15804 break;
15805 default:
15806 bad_subwidg_type("GridY", false, ty);
15807 ret = -10000;
15808 break;
15809 }
15810 }
15811 break;
15812 }
15813 case SUBWIDGTY_ANIMVAL:
15814 {
15815 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "AnimVal"))
15816 {
15817 auto ty = widg->getType();
15818 switch(ty)
15819 {
15820 case widgLGAUGE:
15821 case widgMGAUGE:
15822 case widgMISCGAUGE:
15823 ret = 10000*((SW_GaugePiece*)widg)->anim_val;
15824 break;
15825 default:
15826 bad_subwidg_type("AnimVal", false, ty);
15827 ret = -10000;
15828 break;
15829 }
15830 }
15831 break;
15832 }
15833 case SUBWIDGTY_SHOWDRAIN:
15834 {
15835 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ShowDrain"))
15836 {
15837 auto ty = widg->getType();
15838 switch(ty)
15839 {
15840 case widgMGAUGE:
15841 ret = 10000*((SW_MagicGaugePiece*)widg)->showdrain;
15842 break;
15843 default:
15844 bad_subwidg_type("ShowDrain", false, ty);
15845 ret = -10000;
15846 break;
15847 }
15848 }
15849 break;
15850 }
15851 case SUBWIDGTY_PERCONTAINER:
15852 {
15853 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PerContainer"))
15854 {
15855 auto ty = widg->getType();
15856 switch(ty)
15857 {
15858 case widgMGAUGE:
15859 ret = 10000*((SW_MiscGaugePiece*)widg)->per_container;
15860 break;
15861 default:
15862 bad_subwidg_type("PerContainer", false, ty);
15863 ret = -10000;
15864 break;
15865 }
15866 }
15867 break;
15868 }
15869 case SUBWIDGTY_TABSIZE:
15870 {
15871 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "TabSize"))
15872 {
15873 auto ty = widg->getType();
15874 switch(ty)
15875 {
15876 case widgTEXTBOX:
15877 ret = 10000*((SW_TextBox*)widg)->tabsize;
15878 break;
15879 case widgSELECTEDTEXT:
15880 ret = 10000*((SW_SelectedText*)widg)->tabsize;
15881 break;
15882 default:
15883 bad_subwidg_type("TabSize", false, ty);
15884 ret = -10000;
15885 break;
15886 }
15887 }
15888 break;
15889 }
15890 ///----------------------------------------------------------------------------------------------------//
15891
15892 default:
15893 {
15894
2/4
✓ Branch 0 taken 749311486 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 749311486 times.
749311486 if(arg >= D(0) && arg <= D(7)) ret = ri->d[arg - D(0)];
15895 else if(arg >= A(0) && arg <= A(1)) ret = ri->a[arg - A(0)];
15896 else if(arg >= GD(0) && arg <= GD(MAX_SCRIPT_REGISTERS)) ret = game->global_d[arg - GD(0)];
15897
15898 749311486 break;
15899 }
15900 }
15901
15902
1/2
✓ Branch 0 taken 2760742172 times.
✗ Branch 1 not taken.
2760742172 if ( zasm_debugger ) FFCore.ZASMPrintVarGet(arg, ret);
15903 2760742172 return ret;
15904 }
15905
15906 //Setter Instructions
15907
15908
15909 1399006681 void set_register(int32_t arg, int32_t value)
15910 {
15911
1/2
✓ Branch 0 taken 1399006681 times.
✗ Branch 1 not taken.
1399006681 if ( zasm_debugger ) FFCore.ZASMPrintVarSet(arg, value);
15912 //Macros
15913
15914 #define SET_SPRITEDATA_VAR_INT(member, str) \
15915 { \
15916 if(unsigned(ri->spritesref) > (MAXWPNS-1) ) \
15917 { \
15918 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", str, (ri->spritesref*10000)); \
15919 } \
15920 else \
15921 { \
15922 wpnsbuf[ri->spritesref].member = vbound((value / 10000),0,214747); \
15923 } \
15924 } \
15925
15926 #define SET_SPRITEDATA_VAR_BYTE(member, str) \
15927 { \
15928 if(unsigned(ri->spritesref) > (MAXWPNS-1) ) \
15929 { \
15930 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", str, (ri->spritesref*10000)); \
15931 } \
15932 else \
15933 { \
15934 wpnsbuf[ri->spritesref].member = vbound((value / 10000),0,255); \
15935 } \
15936 } \
15937
15938
239/1331
✓ Branch 0 taken 2881 times.
✓ Branch 1 taken 1217071 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9173 times.
✓ Branch 4 taken 56626 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 461890 times.
✓ Branch 8 taken 236658 times.
✓ Branch 9 taken 78737 times.
✓ Branch 10 taken 222649 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 218369 times.
✓ Branch 13 taken 218461 times.
✓ Branch 14 taken 70141 times.
✓ Branch 15 taken 75916 times.
✓ Branch 16 taken 222649 times.
✓ Branch 17 taken 222649 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 281176 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 61740 times.
✓ Branch 31 taken 10 times.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✓ Branch 34 taken 264908 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 47 times.
✓ Branch 37 taken 23997 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 9747 times.
✗ Branch 40 not taken.
✓ Branch 41 taken 2072 times.
✗ Branch 42 not taken.
✓ Branch 43 taken 41 times.
✓ Branch 44 taken 49622 times.
✓ Branch 45 taken 111461 times.
✗ Branch 46 not taken.
✓ Branch 47 taken 38448 times.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✓ Branch 54 taken 1042699 times.
✓ Branch 55 taken 970520 times.
✗ Branch 56 not taken.
✓ Branch 57 taken 10539 times.
✓ Branch 58 taken 4912 times.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✓ Branch 82 taken 4 times.
✓ Branch 83 taken 900 times.
✓ Branch 84 taken 3579 times.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✓ Branch 94 taken 409929 times.
✓ Branch 95 taken 375716 times.
✓ Branch 96 taken 23554631 times.
✓ Branch 97 taken 78146347 times.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✗ Branch 108 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 114 not taken.
✗ Branch 115 not taken.
✗ Branch 116 not taken.
✓ Branch 117 taken 455505918 times.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✓ Branch 120 taken 261531905 times.
✗ Branch 121 not taken.
✓ Branch 122 taken 2272629 times.
✓ Branch 123 taken 9725 times.
✓ Branch 124 taken 1042466 times.
✓ Branch 125 taken 1215066 times.
✓ Branch 126 taken 9445 times.
✓ Branch 127 taken 9429 times.
✓ Branch 128 taken 9173 times.
✓ Branch 129 taken 229040 times.
✓ Branch 130 taken 3248 times.
✓ Branch 131 taken 3250 times.
✓ Branch 132 taken 9503 times.
✓ Branch 133 taken 9513 times.
✓ Branch 134 taken 616 times.
✓ Branch 135 taken 900 times.
✓ Branch 136 taken 17707 times.
✗ Branch 137 not taken.
✗ Branch 138 not taken.
✓ Branch 139 taken 444601 times.
✗ Branch 140 not taken.
✓ Branch 141 taken 458940 times.
✓ Branch 142 taken 2769 times.
✓ Branch 143 taken 64379 times.
✗ Branch 144 not taken.
✓ Branch 145 taken 93694 times.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✗ Branch 148 not taken.
✓ Branch 149 taken 270553 times.
✓ Branch 150 taken 10415 times.
✓ Branch 151 taken 56 times.
✗ Branch 152 not taken.
✓ Branch 153 taken 388 times.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✗ Branch 156 not taken.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✓ Branch 159 taken 5906 times.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✓ Branch 162 taken 740 times.
✓ Branch 163 taken 1532 times.
✗ Branch 164 not taken.
✓ Branch 165 taken 4 times.
✓ Branch 166 taken 5161 times.
✗ Branch 167 not taken.
✗ Branch 168 not taken.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✗ Branch 171 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✗ Branch 174 not taken.
✓ Branch 175 taken 280560 times.
✗ Branch 176 not taken.
✗ Branch 177 not taken.
✗ Branch 178 not taken.
✗ Branch 179 not taken.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 183 not taken.
✗ Branch 184 not taken.
✗ Branch 185 not taken.
✗ Branch 186 not taken.
✗ Branch 187 not taken.
✗ Branch 188 not taken.
✓ Branch 189 taken 93758 times.
✓ Branch 190 taken 93759 times.
✓ Branch 191 taken 93772 times.
✓ Branch 192 taken 93778 times.
✗ Branch 193 not taken.
✗ Branch 194 not taken.
✗ Branch 195 not taken.
✗ Branch 196 not taken.
✗ Branch 197 not taken.
✓ Branch 198 taken 2569 times.
✗ Branch 199 not taken.
✓ Branch 200 taken 2569 times.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✗ Branch 207 not taken.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✗ Branch 210 not taken.
✗ Branch 211 not taken.
✗ Branch 212 not taken.
✓ Branch 213 taken 166 times.
✗ Branch 214 not taken.
✗ Branch 215 not taken.
✗ Branch 216 not taken.
✗ Branch 217 not taken.
✗ Branch 218 not taken.
✗ Branch 219 not taken.
✗ Branch 220 not taken.
✗ Branch 221 not taken.
✗ Branch 222 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✓ Branch 228 taken 928305 times.
✓ Branch 229 taken 249228 times.
✓ Branch 230 taken 249220 times.
✓ Branch 231 taken 236880 times.
✓ Branch 232 taken 89166 times.
✓ Branch 233 taken 76223 times.
✓ Branch 234 taken 78784 times.
✓ Branch 235 taken 222649 times.
✓ Branch 236 taken 222649 times.
✓ Branch 237 taken 222649 times.
✗ Branch 238 not taken.
✗ Branch 239 not taken.
✗ Branch 240 not taken.
✓ Branch 241 taken 928305 times.
✓ Branch 242 taken 461890 times.
✓ Branch 243 taken 218364 times.
✓ Branch 244 taken 218431 times.
✓ Branch 245 taken 83086 times.
✓ Branch 246 taken 75869 times.
✓ Branch 247 taken 222649 times.
✓ Branch 248 taken 222649 times.
✗ Branch 249 not taken.
✗ Branch 250 not taken.
✗ Branch 251 not taken.
✗ Branch 252 not taken.
✓ Branch 253 taken 281262 times.
✗ Branch 254 not taken.
✗ Branch 255 not taken.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✗ Branch 258 not taken.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✗ Branch 261 not taken.
✗ Branch 262 not taken.
✗ Branch 263 not taken.
✗ Branch 264 not taken.
✓ Branch 265 taken 21848 times.
✓ Branch 266 taken 31 times.
✗ Branch 267 not taken.
✓ Branch 268 taken 41791 times.
✓ Branch 269 taken 92 times.
✓ Branch 270 taken 49959 times.
✗ Branch 271 not taken.
✗ Branch 272 not taken.
✓ Branch 273 taken 37 times.
✗ Branch 274 not taken.
✓ Branch 275 taken 109 times.
✗ Branch 276 not taken.
✗ Branch 277 not taken.
✗ Branch 278 not taken.
✗ Branch 279 not taken.
✗ Branch 280 not taken.
✓ Branch 281 taken 40 times.
✗ Branch 282 not taken.
✗ Branch 283 not taken.
✗ Branch 284 not taken.
✗ Branch 285 not taken.
✗ Branch 286 not taken.
✗ Branch 287 not taken.
✗ Branch 288 not taken.
✗ Branch 289 not taken.
✗ Branch 290 not taken.
✗ Branch 291 not taken.
✗ Branch 292 not taken.
✗ Branch 293 not taken.
✗ Branch 294 not taken.
✓ Branch 295 taken 6 times.
✗ Branch 296 not taken.
✗ Branch 297 not taken.
✗ Branch 298 not taken.
✗ Branch 299 not taken.
✗ Branch 300 not taken.
✗ Branch 301 not taken.
✗ Branch 302 not taken.
✓ Branch 303 taken 1181 times.
✓ Branch 304 taken 3013 times.
✗ Branch 305 not taken.
✗ Branch 306 not taken.
✗ Branch 307 not taken.
✗ Branch 308 not taken.
✗ Branch 309 not taken.
✓ Branch 310 taken 68 times.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✗ Branch 314 not taken.
✗ Branch 315 not taken.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✗ Branch 319 not taken.
✗ Branch 320 not taken.
✗ Branch 321 not taken.
✗ Branch 322 not taken.
✗ Branch 323 not taken.
✗ Branch 324 not taken.
✗ Branch 325 not taken.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✗ Branch 328 not taken.
✗ Branch 329 not taken.
✗ Branch 330 not taken.
✗ Branch 331 not taken.
✗ Branch 332 not taken.
✗ Branch 333 not taken.
✗ Branch 334 not taken.
✗ Branch 335 not taken.
✗ Branch 336 not taken.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✗ Branch 339 not taken.
✗ Branch 340 not taken.
✗ Branch 341 not taken.
✗ Branch 342 not taken.
✗ Branch 343 not taken.
✗ Branch 344 not taken.
✗ Branch 345 not taken.
✗ Branch 346 not taken.
✗ Branch 347 not taken.
✗ Branch 348 not taken.
✗ Branch 349 not taken.
✗ Branch 350 not taken.
✗ Branch 351 not taken.
✗ Branch 352 not taken.
✗ Branch 353 not taken.
✗ Branch 354 not taken.
✗ Branch 355 not taken.
✗ Branch 356 not taken.
✗ Branch 357 not taken.
✗ Branch 358 not taken.
✗ Branch 359 not taken.
✗ Branch 360 not taken.
✗ Branch 361 not taken.
✗ Branch 362 not taken.
✗ Branch 363 not taken.
✗ Branch 364 not taken.
✗ Branch 365 not taken.
✗ Branch 366 not taken.
✗ Branch 367 not taken.
✗ Branch 368 not taken.
✗ Branch 369 not taken.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✗ Branch 372 not taken.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
✗ Branch 376 not taken.
✗ Branch 377 not taken.
✗ Branch 378 not taken.
✗ Branch 379 not taken.
✗ Branch 380 not taken.
✗ Branch 381 not taken.
✗ Branch 382 not taken.
✗ Branch 383 not taken.
✓ Branch 384 taken 2760 times.
✗ Branch 385 not taken.
✗ Branch 386 not taken.
✗ Branch 387 not taken.
✗ Branch 388 not taken.
✗ Branch 389 not taken.
✗ Branch 390 not taken.
✗ Branch 391 not taken.
✓ Branch 392 taken 70 times.
✗ Branch 393 not taken.
✗ Branch 394 not taken.
✗ Branch 395 not taken.
✗ Branch 396 not taken.
✗ Branch 397 not taken.
✗ Branch 398 not taken.
✗ Branch 399 not taken.
✓ Branch 400 taken 193740 times.
✗ Branch 401 not taken.
✓ Branch 402 taken 193733 times.
✗ Branch 403 not taken.
✓ Branch 404 taken 180 times.
✗ Branch 405 not taken.
✓ Branch 406 taken 65038 times.
✗ Branch 407 not taken.
✓ Branch 408 taken 8276 times.
✓ Branch 409 taken 1469 times.
✗ Branch 410 not taken.
✗ Branch 411 not taken.
✗ Branch 412 not taken.
✓ Branch 413 taken 1175 times.
✗ Branch 414 not taken.
✗ Branch 415 not taken.
✓ Branch 416 taken 49 times.
✓ Branch 417 taken 69347 times.
✓ Branch 418 taken 139174 times.
✗ Branch 419 not taken.
✓ Branch 420 taken 1853 times.
✗ Branch 421 not taken.
✗ Branch 422 not taken.
✓ Branch 423 taken 2049 times.
✗ Branch 424 not taken.
✓ Branch 425 taken 404 times.
✗ Branch 426 not taken.
✓ Branch 427 taken 457 times.
✗ Branch 428 not taken.
✓ Branch 429 taken 683 times.
✓ Branch 430 taken 4922 times.
✓ Branch 431 taken 16 times.
✓ Branch 432 taken 1841 times.
✗ Branch 433 not taken.
✓ Branch 434 taken 60616 times.
✓ Branch 435 taken 60616 times.
✓ Branch 436 taken 156 times.
✓ Branch 437 taken 63470 times.
✗ Branch 438 not taken.
✗ Branch 439 not taken.
✗ Branch 440 not taken.
✗ Branch 441 not taken.
✓ Branch 442 taken 61757 times.
✗ Branch 443 not taken.
✓ Branch 444 taken 10 times.
✓ Branch 445 taken 497624 times.
✓ Branch 446 taken 16104 times.
✗ Branch 447 not taken.
✗ Branch 448 not taken.
✗ Branch 449 not taken.
✓ Branch 450 taken 60886 times.
✓ Branch 451 taken 603 times.
✓ Branch 452 taken 206 times.
✗ Branch 453 not taken.
✗ Branch 454 not taken.
✗ Branch 455 not taken.
✗ Branch 456 not taken.
✓ Branch 457 taken 265 times.
✗ Branch 458 not taken.
✗ Branch 459 not taken.
✗ Branch 460 not taken.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✗ Branch 463 not taken.
✗ Branch 464 not taken.
✗ Branch 465 not taken.
✗ Branch 466 not taken.
✗ Branch 467 not taken.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✗ Branch 471 not taken.
✗ Branch 472 not taken.
✗ Branch 473 not taken.
✓ Branch 474 taken 226569 times.
✗ Branch 475 not taken.
✓ Branch 476 taken 226856 times.
✓ Branch 477 taken 6823 times.
✓ Branch 478 taken 6048 times.
✗ Branch 479 not taken.
✓ Branch 480 taken 138270 times.
✗ Branch 481 not taken.
✗ Branch 482 not taken.
✓ Branch 483 taken 134925 times.
✗ Branch 484 not taken.
✗ Branch 485 not taken.
✓ Branch 486 taken 131702 times.
✗ Branch 487 not taken.
✓ Branch 488 taken 12175 times.
✓ Branch 489 taken 132679 times.
✗ Branch 490 not taken.
✗ Branch 491 not taken.
✓ Branch 492 taken 41 times.
✓ Branch 493 taken 549 times.
✓ Branch 494 taken 1104 times.
✓ Branch 495 taken 4552 times.
✓ Branch 496 taken 138269 times.
✓ Branch 497 taken 137776 times.
✓ Branch 498 taken 35370 times.
✗ Branch 499 not taken.
✗ Branch 500 not taken.
✓ Branch 501 taken 234661 times.
✓ Branch 502 taken 234074 times.
✓ Branch 503 taken 44 times.
✓ Branch 504 taken 111461 times.
✓ Branch 505 taken 111461 times.
✓ Branch 506 taken 910117 times.
✓ Branch 507 taken 20016 times.
✗ Branch 508 not taken.
✗ Branch 509 not taken.
✗ Branch 510 not taken.
✓ Branch 511 taken 1275 times.
✓ Branch 512 taken 4214 times.
✗ Branch 513 not taken.
✗ Branch 514 not taken.
✗ Branch 515 not taken.
✗ Branch 516 not taken.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✗ Branch 519 not taken.
✗ Branch 520 not taken.
✗ Branch 521 not taken.
✗ Branch 522 not taken.
✗ Branch 523 not taken.
✗ Branch 524 not taken.
✗ Branch 525 not taken.
✗ Branch 526 not taken.
✗ Branch 527 not taken.
✗ Branch 528 not taken.
✗ Branch 529 not taken.
✗ Branch 530 not taken.
✗ Branch 531 not taken.
✓ Branch 532 taken 1038288 times.
✗ Branch 533 not taken.
✓ Branch 534 taken 3 times.
✗ Branch 535 not taken.
✗ Branch 536 not taken.
✓ Branch 537 taken 973735 times.
✗ Branch 538 not taken.
✓ Branch 539 taken 71 times.
✗ Branch 540 not taken.
✓ Branch 541 taken 21269 times.
✓ Branch 542 taken 28037 times.
✗ Branch 543 not taken.
✗ Branch 544 not taken.
✗ Branch 545 not taken.
✗ Branch 546 not taken.
✗ Branch 547 not taken.
✗ Branch 548 not taken.
✓ Branch 549 taken 1046835 times.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✗ Branch 552 not taken.
✗ Branch 553 not taken.
✗ Branch 554 not taken.
✗ Branch 555 not taken.
✗ Branch 556 not taken.
✗ Branch 557 not taken.
✗ Branch 558 not taken.
✓ Branch 559 taken 3 times.
✗ Branch 560 not taken.
✓ Branch 561 taken 4414 times.
✓ Branch 562 taken 1034127 times.
✗ Branch 563 not taken.
✓ Branch 564 taken 788 times.
✗ Branch 565 not taken.
✓ Branch 566 taken 321 times.
✓ Branch 567 taken 94 times.
✗ Branch 568 not taken.
✓ Branch 569 taken 13 times.
✓ Branch 570 taken 77612 times.
✓ Branch 571 taken 1181 times.
✓ Branch 572 taken 4183 times.
✓ Branch 573 taken 7068 times.
✓ Branch 574 taken 7068 times.
✓ Branch 575 taken 2 times.
✓ Branch 576 taken 28759 times.
✗ Branch 577 not taken.
✓ Branch 578 taken 1094 times.
✗ Branch 579 not taken.
✓ Branch 580 taken 1020506 times.
✓ Branch 581 taken 10539 times.
✓ Branch 582 taken 8696 times.
✗ Branch 583 not taken.
✗ Branch 584 not taken.
✗ Branch 585 not taken.
✓ Branch 586 taken 545362 times.
✗ Branch 587 not taken.
✓ Branch 588 taken 2614735 times.
✗ Branch 589 not taken.
✗ Branch 590 not taken.
✗ Branch 591 not taken.
✗ Branch 592 not taken.
✗ Branch 593 not taken.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✗ Branch 596 not taken.
✗ Branch 597 not taken.
✗ Branch 598 not taken.
✗ Branch 599 not taken.
✗ Branch 600 not taken.
✗ Branch 601 not taken.
✗ Branch 602 not taken.
✗ Branch 603 not taken.
✗ Branch 604 not taken.
✗ Branch 605 not taken.
✗ Branch 606 not taken.
✗ Branch 607 not taken.
✗ Branch 608 not taken.
✗ Branch 609 not taken.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 612 not taken.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✗ Branch 615 not taken.
✗ Branch 616 not taken.
✓ Branch 617 taken 26 times.
✓ Branch 618 taken 88964 times.
✓ Branch 619 taken 88964 times.
✓ Branch 620 taken 88970 times.
✓ Branch 621 taken 88970 times.
✓ Branch 622 taken 2705905 times.
✓ Branch 623 taken 551 times.
✓ Branch 624 taken 8 times.
✗ Branch 625 not taken.
✗ Branch 626 not taken.
✗ Branch 627 not taken.
✗ Branch 628 not taken.
✓ Branch 629 taken 131 times.
✓ Branch 630 taken 64 times.
✗ Branch 631 not taken.
✗ Branch 632 not taken.
✗ Branch 633 not taken.
✗ Branch 634 not taken.
✗ Branch 635 not taken.
✗ Branch 636 not taken.
✗ Branch 637 not taken.
✗ Branch 638 not taken.
✗ Branch 639 not taken.
✗ Branch 640 not taken.
✗ Branch 641 not taken.
✗ Branch 642 not taken.
✓ Branch 643 taken 3 times.
✗ Branch 644 not taken.
✓ Branch 645 taken 394 times.
✗ Branch 646 not taken.
✗ Branch 647 not taken.
✗ Branch 648 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✓ Branch 651 taken 649 times.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✗ Branch 654 not taken.
✗ Branch 655 not taken.
✗ Branch 656 not taken.
✗ Branch 657 not taken.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✗ Branch 660 not taken.
✗ Branch 661 not taken.
✗ Branch 662 not taken.
✗ Branch 663 not taken.
✓ Branch 664 taken 377 times.
✗ Branch 665 not taken.
✓ Branch 666 taken 120341 times.
✓ Branch 667 taken 6481 times.
✗ Branch 668 not taken.
✓ Branch 669 taken 3560 times.
✗ Branch 670 not taken.
✓ Branch 671 taken 81346 times.
✗ Branch 672 not taken.
✓ Branch 673 taken 5356632 times.
✓ Branch 674 taken 5344380 times.
✓ Branch 675 taken 32221 times.
✓ Branch 676 taken 760 times.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✗ Branch 679 not taken.
✗ Branch 680 not taken.
✗ Branch 681 not taken.
✗ Branch 682 not taken.
✗ Branch 683 not taken.
✗ Branch 684 not taken.
✗ Branch 685 not taken.
✗ Branch 686 not taken.
✗ Branch 687 not taken.
✗ Branch 688 not taken.
✗ Branch 689 not taken.
✗ Branch 690 not taken.
✗ Branch 691 not taken.
✗ Branch 692 not taken.
✗ Branch 693 not taken.
✗ Branch 694 not taken.
✗ Branch 695 not taken.
✗ Branch 696 not taken.
✗ Branch 697 not taken.
✗ Branch 698 not taken.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✗ Branch 702 not taken.
✗ Branch 703 not taken.
✗ Branch 704 not taken.
✗ Branch 705 not taken.
✗ Branch 706 not taken.
✗ Branch 707 not taken.
✗ Branch 708 not taken.
✗ Branch 709 not taken.
✗ Branch 710 not taken.
✗ Branch 711 not taken.
✗ Branch 712 not taken.
✗ Branch 713 not taken.
✗ Branch 714 not taken.
✗ Branch 715 not taken.
✓ Branch 716 taken 128 times.
✓ Branch 717 taken 128 times.
✓ Branch 718 taken 128 times.
✗ Branch 719 not taken.
✗ Branch 720 not taken.
✗ Branch 721 not taken.
✗ Branch 722 not taken.
✓ Branch 723 taken 5 times.
✓ Branch 724 taken 5 times.
✗ Branch 725 not taken.
✗ Branch 726 not taken.
✗ Branch 727 not taken.
✗ Branch 728 not taken.
✗ Branch 729 not taken.
✗ Branch 730 not taken.
✗ Branch 731 not taken.
✗ Branch 732 not taken.
✗ Branch 733 not taken.
✗ Branch 734 not taken.
✗ Branch 735 not taken.
✗ Branch 736 not taken.
✗ Branch 737 not taken.
✗ Branch 738 not taken.
✗ Branch 739 not taken.
✗ Branch 740 not taken.
✗ Branch 741 not taken.
✗ Branch 742 not taken.
✗ Branch 743 not taken.
✗ Branch 744 not taken.
✗ Branch 745 not taken.
✗ Branch 746 not taken.
✗ Branch 747 not taken.
✗ Branch 748 not taken.
✗ Branch 749 not taken.
✗ Branch 750 not taken.
✗ Branch 751 not taken.
✗ Branch 752 not taken.
✗ Branch 753 not taken.
✗ Branch 754 not taken.
✗ Branch 755 not taken.
✗ Branch 756 not taken.
✗ Branch 757 not taken.
✗ Branch 758 not taken.
✗ Branch 759 not taken.
✗ Branch 760 not taken.
✗ Branch 761 not taken.
✗ Branch 762 not taken.
✓ Branch 763 taken 14277 times.
✗ Branch 764 not taken.
✓ Branch 765 taken 27297 times.
✓ Branch 766 taken 531 times.
✗ Branch 767 not taken.
✗ Branch 768 not taken.
✓ Branch 769 taken 7214 times.
✗ Branch 770 not taken.
✓ Branch 771 taken 11 times.
✗ Branch 772 not taken.
✗ Branch 773 not taken.
✗ Branch 774 not taken.
✗ Branch 775 not taken.
✗ Branch 776 not taken.
✗ Branch 777 not taken.
✗ Branch 778 not taken.
✗ Branch 779 not taken.
✗ Branch 780 not taken.
✗ Branch 781 not taken.
✗ Branch 782 not taken.
✗ Branch 783 not taken.
✗ Branch 784 not taken.
✗ Branch 785 not taken.
✗ Branch 786 not taken.
✗ Branch 787 not taken.
✗ Branch 788 not taken.
✗ Branch 789 not taken.
✗ Branch 790 not taken.
✗ Branch 791 not taken.
✗ Branch 792 not taken.
✗ Branch 793 not taken.
✗ Branch 794 not taken.
✗ Branch 795 not taken.
✗ Branch 796 not taken.
✗ Branch 797 not taken.
✗ Branch 798 not taken.
✗ Branch 799 not taken.
✗ Branch 800 not taken.
✗ Branch 801 not taken.
✗ Branch 802 not taken.
✗ Branch 803 not taken.
✗ Branch 804 not taken.
✗ Branch 805 not taken.
✗ Branch 806 not taken.
✗ Branch 807 not taken.
✗ Branch 808 not taken.
✗ Branch 809 not taken.
✗ Branch 810 not taken.
✗ Branch 811 not taken.
✗ Branch 812 not taken.
✗ Branch 813 not taken.
✗ Branch 814 not taken.
✗ Branch 815 not taken.
✗ Branch 816 not taken.
✗ Branch 817 not taken.
✗ Branch 818 not taken.
✗ Branch 819 not taken.
✗ Branch 820 not taken.
✗ Branch 821 not taken.
✗ Branch 822 not taken.
✗ Branch 823 not taken.
✗ Branch 824 not taken.
✗ Branch 825 not taken.
✗ Branch 826 not taken.
✗ Branch 827 not taken.
✗ Branch 828 not taken.
✗ Branch 829 not taken.
✗ Branch 830 not taken.
✗ Branch 831 not taken.
✗ Branch 832 not taken.
✗ Branch 833 not taken.
✗ Branch 834 not taken.
✗ Branch 835 not taken.
✗ Branch 836 not taken.
✗ Branch 837 not taken.
✗ Branch 838 not taken.
✗ Branch 839 not taken.
✗ Branch 840 not taken.
✗ Branch 841 not taken.
✗ Branch 842 not taken.
✗ Branch 843 not taken.
✗ Branch 844 not taken.
✗ Branch 845 not taken.
✗ Branch 846 not taken.
✗ Branch 847 not taken.
✗ Branch 848 not taken.
✗ Branch 849 not taken.
✗ Branch 850 not taken.
✗ Branch 851 not taken.
✗ Branch 852 not taken.
✗ Branch 853 not taken.
✗ Branch 854 not taken.
✗ Branch 855 not taken.
✗ Branch 856 not taken.
✗ Branch 857 not taken.
✗ Branch 858 not taken.
✗ Branch 859 not taken.
✗ Branch 860 not taken.
✗ Branch 861 not taken.
✗ Branch 862 not taken.
✗ Branch 863 not taken.
✗ Branch 864 not taken.
✗ Branch 865 not taken.
✗ Branch 866 not taken.
✗ Branch 867 not taken.
✗ Branch 868 not taken.
✗ Branch 869 not taken.
✗ Branch 870 not taken.
✗ Branch 871 not taken.
✗ Branch 872 not taken.
✗ Branch 873 not taken.
✗ Branch 874 not taken.
✗ Branch 875 not taken.
✗ Branch 876 not taken.
✗ Branch 877 not taken.
✗ Branch 878 not taken.
✗ Branch 879 not taken.
✗ Branch 880 not taken.
✓ Branch 881 taken 80782 times.
✓ Branch 882 taken 2497 times.
✓ Branch 883 taken 56174 times.
✗ Branch 884 not taken.
✗ Branch 885 not taken.
✗ Branch 886 not taken.
✗ Branch 887 not taken.
✗ Branch 888 not taken.
✗ Branch 889 not taken.
✗ Branch 890 not taken.
✗ Branch 891 not taken.
✗ Branch 892 not taken.
✗ Branch 893 not taken.
✗ Branch 894 not taken.
✗ Branch 895 not taken.
✗ Branch 896 not taken.
✗ Branch 897 not taken.
✗ Branch 898 not taken.
✗ Branch 899 not taken.
✗ Branch 900 not taken.
✗ Branch 901 not taken.
✗ Branch 902 not taken.
✗ Branch 903 not taken.
✗ Branch 904 not taken.
✗ Branch 905 not taken.
✗ Branch 906 not taken.
✗ Branch 907 not taken.
✗ Branch 908 not taken.
✗ Branch 909 not taken.
✗ Branch 910 not taken.
✗ Branch 911 not taken.
✗ Branch 912 not taken.
✗ Branch 913 not taken.
✗ Branch 914 not taken.
✗ Branch 915 not taken.
✗ Branch 916 not taken.
✗ Branch 917 not taken.
✗ Branch 918 not taken.
✗ Branch 919 not taken.
✗ Branch 920 not taken.
✗ Branch 921 not taken.
✗ Branch 922 not taken.
✗ Branch 923 not taken.
✗ Branch 924 not taken.
✗ Branch 925 not taken.
✗ Branch 926 not taken.
✗ Branch 927 not taken.
✓ Branch 928 taken 3225 times.
✗ Branch 929 not taken.
✗ Branch 930 not taken.
✗ Branch 931 not taken.
✗ Branch 932 not taken.
✗ Branch 933 not taken.
✗ Branch 934 not taken.
✗ Branch 935 not taken.
✗ Branch 936 not taken.
✗ Branch 937 not taken.
✗ Branch 938 not taken.
✗ Branch 939 not taken.
✗ Branch 940 not taken.
✗ Branch 941 not taken.
✗ Branch 942 not taken.
✗ Branch 943 not taken.
✗ Branch 944 not taken.
✗ Branch 945 not taken.
✗ Branch 946 not taken.
✗ Branch 947 not taken.
✗ Branch 948 not taken.
✗ Branch 949 not taken.
✗ Branch 950 not taken.
✗ Branch 951 not taken.
✗ Branch 952 not taken.
✗ Branch 953 not taken.
✗ Branch 954 not taken.
✗ Branch 955 not taken.
✗ Branch 956 not taken.
✗ Branch 957 not taken.
✗ Branch 958 not taken.
✗ Branch 959 not taken.
✗ Branch 960 not taken.
✗ Branch 961 not taken.
✗ Branch 962 not taken.
✗ Branch 963 not taken.
✗ Branch 964 not taken.
✗ Branch 965 not taken.
✗ Branch 966 not taken.
✗ Branch 967 not taken.
✗ Branch 968 not taken.
✗ Branch 969 not taken.
✗ Branch 970 not taken.
✗ Branch 971 not taken.
✗ Branch 972 not taken.
✗ Branch 973 not taken.
✗ Branch 974 not taken.
✗ Branch 975 not taken.
✗ Branch 976 not taken.
✗ Branch 977 not taken.
✗ Branch 978 not taken.
✗ Branch 979 not taken.
✗ Branch 980 not taken.
✗ Branch 981 not taken.
✗ Branch 982 not taken.
✗ Branch 983 not taken.
✗ Branch 984 not taken.
✗ Branch 985 not taken.
✗ Branch 986 not taken.
✗ Branch 987 not taken.
✗ Branch 988 not taken.
✗ Branch 989 not taken.
✗ Branch 990 not taken.
✗ Branch 991 not taken.
✗ Branch 992 not taken.
✗ Branch 993 not taken.
✗ Branch 994 not taken.
✗ Branch 995 not taken.
✗ Branch 996 not taken.
✗ Branch 997 not taken.
✗ Branch 998 not taken.
✗ Branch 999 not taken.
✗ Branch 1000 not taken.
✗ Branch 1001 not taken.
✗ Branch 1002 not taken.
✗ Branch 1003 not taken.
✗ Branch 1004 not taken.
✗ Branch 1005 not taken.
✗ Branch 1006 not taken.
✗ Branch 1007 not taken.
✗ Branch 1008 not taken.
✗ Branch 1009 not taken.
✗ Branch 1010 not taken.
✗ Branch 1011 not taken.
✗ Branch 1012 not taken.
✗ Branch 1013 not taken.
✗ Branch 1014 not taken.
✗ Branch 1015 not taken.
✗ Branch 1016 not taken.
✗ Branch 1017 not taken.
✗ Branch 1018 not taken.
✗ Branch 1019 not taken.
✗ Branch 1020 not taken.
✗ Branch 1021 not taken.
✗ Branch 1022 not taken.
✗ Branch 1023 not taken.
✗ Branch 1024 not taken.
✗ Branch 1025 not taken.
✗ Branch 1026 not taken.
✗ Branch 1027 not taken.
✗ Branch 1028 not taken.
✗ Branch 1029 not taken.
✗ Branch 1030 not taken.
✗ Branch 1031 not taken.
✗ Branch 1032 not taken.
✗ Branch 1033 not taken.
✗ Branch 1034 not taken.
✗ Branch 1035 not taken.
✗ Branch 1036 not taken.
✗ Branch 1037 not taken.
✗ Branch 1038 not taken.
✗ Branch 1039 not taken.
✗ Branch 1040 not taken.
✗ Branch 1041 not taken.
✗ Branch 1042 not taken.
✗ Branch 1043 not taken.
✗ Branch 1044 not taken.
✗ Branch 1045 not taken.
✗ Branch 1046 not taken.
✗ Branch 1047 not taken.
✗ Branch 1048 not taken.
✗ Branch 1049 not taken.
✗ Branch 1050 not taken.
✗ Branch 1051 not taken.
✗ Branch 1052 not taken.
✗ Branch 1053 not taken.
✗ Branch 1054 not taken.
✗ Branch 1055 not taken.
✗ Branch 1056 not taken.
✗ Branch 1057 not taken.
✗ Branch 1058 not taken.
✗ Branch 1059 not taken.
✗ Branch 1060 not taken.
✗ Branch 1061 not taken.
✗ Branch 1062 not taken.
✗ Branch 1063 not taken.
✗ Branch 1064 not taken.
✗ Branch 1065 not taken.
✗ Branch 1066 not taken.
✗ Branch 1067 not taken.
✗ Branch 1068 not taken.
✗ Branch 1069 not taken.
✗ Branch 1070 not taken.
✗ Branch 1071 not taken.
✗ Branch 1072 not taken.
✗ Branch 1073 not taken.
✗ Branch 1074 not taken.
✗ Branch 1075 not taken.
✗ Branch 1076 not taken.
✗ Branch 1077 not taken.
✗ Branch 1078 not taken.
✗ Branch 1079 not taken.
✗ Branch 1080 not taken.
✗ Branch 1081 not taken.
✗ Branch 1082 not taken.
✗ Branch 1083 not taken.
✗ Branch 1084 not taken.
✗ Branch 1085 not taken.
✗ Branch 1086 not taken.
✗ Branch 1087 not taken.
✗ Branch 1088 not taken.
✗ Branch 1089 not taken.
✗ Branch 1090 not taken.
✗ Branch 1091 not taken.
✗ Branch 1092 not taken.
✗ Branch 1093 not taken.
✗ Branch 1094 not taken.
✗ Branch 1095 not taken.
✗ Branch 1096 not taken.
✗ Branch 1097 not taken.
✗ Branch 1098 not taken.
✗ Branch 1099 not taken.
✗ Branch 1100 not taken.
✗ Branch 1101 not taken.
✗ Branch 1102 not taken.
✗ Branch 1103 not taken.
✗ Branch 1104 not taken.
✗ Branch 1105 not taken.
✗ Branch 1106 not taken.
✗ Branch 1107 not taken.
✗ Branch 1108 not taken.
✗ Branch 1109 not taken.
✗ Branch 1110 not taken.
✗ Branch 1111 not taken.
✗ Branch 1112 not taken.
✗ Branch 1113 not taken.
✗ Branch 1114 not taken.
✗ Branch 1115 not taken.
✗ Branch 1116 not taken.
✗ Branch 1117 not taken.
✗ Branch 1118 not taken.
✗ Branch 1119 not taken.
✗ Branch 1120 not taken.
✗ Branch 1121 not taken.
✗ Branch 1122 not taken.
✗ Branch 1123 not taken.
✗ Branch 1124 not taken.
✗ Branch 1125 not taken.
✗ Branch 1126 not taken.
✗ Branch 1127 not taken.
✗ Branch 1128 not taken.
✗ Branch 1129 not taken.
✗ Branch 1130 not taken.
✗ Branch 1131 not taken.
✗ Branch 1132 not taken.
✗ Branch 1133 not taken.
✗ Branch 1134 not taken.
✗ Branch 1135 not taken.
✗ Branch 1136 not taken.
✗ Branch 1137 not taken.
✗ Branch 1138 not taken.
✗ Branch 1139 not taken.
✗ Branch 1140 not taken.
✗ Branch 1141 not taken.
✗ Branch 1142 not taken.
✗ Branch 1143 not taken.
✗ Branch 1144 not taken.
✗ Branch 1145 not taken.
✗ Branch 1146 not taken.
✗ Branch 1147 not taken.
✗ Branch 1148 not taken.
✗ Branch 1149 not taken.
✗ Branch 1150 not taken.
✗ Branch 1151 not taken.
✓ Branch 1152 taken 503812260 times.
✓ Branch 1153 taken 10112990 times.
✓ Branch 1154 taken 18513311 times.
✗ Branch 1155 not taken.
✓ Branch 1156 taken 116558 times.
✗ Branch 1157 not taken.
✓ Branch 1158 taken 257126 times.
✗ Branch 1159 not taken.
✓ Branch 1160 taken 760115 times.
✗ Branch 1161 not taken.
✗ Branch 1162 not taken.
✗ Branch 1163 not taken.
✗ Branch 1164 not taken.
✗ Branch 1165 not taken.
✓ Branch 1166 taken 142 times.
✗ Branch 1167 not taken.
✗ Branch 1168 not taken.
✗ Branch 1169 not taken.
✗ Branch 1170 not taken.
✗ Branch 1171 not taken.
✗ Branch 1172 not taken.
✓ Branch 1173 taken 284 times.
✗ Branch 1174 not taken.
✗ Branch 1175 not taken.
✗ Branch 1176 not taken.
✗ Branch 1177 not taken.
✗ Branch 1178 not taken.
✓ Branch 1179 taken 303330 times.
✗ Branch 1180 not taken.
✗ Branch 1181 not taken.
✗ Branch 1182 not taken.
✗ Branch 1183 not taken.
✗ Branch 1184 not taken.
✗ Branch 1185 not taken.
✗ Branch 1186 not taken.
✓ Branch 1187 taken 58 times.
✗ Branch 1188 not taken.
✗ Branch 1189 not taken.
✓ Branch 1190 taken 74 times.
✗ Branch 1191 not taken.
✗ Branch 1192 not taken.
✗ Branch 1193 not taken.
✗ Branch 1194 not taken.
✗ Branch 1195 not taken.
✗ Branch 1196 not taken.
✗ Branch 1197 not taken.
✗ Branch 1198 not taken.
✗ Branch 1199 not taken.
✗ Branch 1200 not taken.
✗ Branch 1201 not taken.
✗ Branch 1202 not taken.
✗ Branch 1203 not taken.
✗ Branch 1204 not taken.
✗ Branch 1205 not taken.
✗ Branch 1206 not taken.
✗ Branch 1207 not taken.
✗ Branch 1208 not taken.
✗ Branch 1209 not taken.
✗ Branch 1210 not taken.
✗ Branch 1211 not taken.
✗ Branch 1212 not taken.
✗ Branch 1213 not taken.
✗ Branch 1214 not taken.
✗ Branch 1215 not taken.
✗ Branch 1216 not taken.
✗ Branch 1217 not taken.
✗ Branch 1218 not taken.
✗ Branch 1219 not taken.
✗ Branch 1220 not taken.
✗ Branch 1221 not taken.
✗ Branch 1222 not taken.
✗ Branch 1223 not taken.
✗ Branch 1224 not taken.
✗ Branch 1225 not taken.
✗ Branch 1226 not taken.
✗ Branch 1227 not taken.
✗ Branch 1228 not taken.
✗ Branch 1229 not taken.
✗ Branch 1230 not taken.
✗ Branch 1231 not taken.
✗ Branch 1232 not taken.
✗ Branch 1233 not taken.
✗ Branch 1234 not taken.
✗ Branch 1235 not taken.
✗ Branch 1236 not taken.
✗ Branch 1237 not taken.
✗ Branch 1238 not taken.
✗ Branch 1239 not taken.
✗ Branch 1240 not taken.
✗ Branch 1241 not taken.
✗ Branch 1242 not taken.
✗ Branch 1243 not taken.
✗ Branch 1244 not taken.
✗ Branch 1245 not taken.
✗ Branch 1246 not taken.
✗ Branch 1247 not taken.
✗ Branch 1248 not taken.
✗ Branch 1249 not taken.
✗ Branch 1250 not taken.
✗ Branch 1251 not taken.
✗ Branch 1252 not taken.
✗ Branch 1253 not taken.
✗ Branch 1254 not taken.
✗ Branch 1255 not taken.
✗ Branch 1256 not taken.
✗ Branch 1257 not taken.
✗ Branch 1258 not taken.
✗ Branch 1259 not taken.
✗ Branch 1260 not taken.
✗ Branch 1261 not taken.
✗ Branch 1262 not taken.
✗ Branch 1263 not taken.
✗ Branch 1264 not taken.
✗ Branch 1265 not taken.
✗ Branch 1266 not taken.
✗ Branch 1267 not taken.
✗ Branch 1268 not taken.
✗ Branch 1269 not taken.
✗ Branch 1270 not taken.
✗ Branch 1271 not taken.
✗ Branch 1272 not taken.
✗ Branch 1273 not taken.
✗ Branch 1274 not taken.
✗ Branch 1275 not taken.
✗ Branch 1276 not taken.
✗ Branch 1277 not taken.
✗ Branch 1278 not taken.
✗ Branch 1279 not taken.
✗ Branch 1280 not taken.
✗ Branch 1281 not taken.
✗ Branch 1282 not taken.
✗ Branch 1283 not taken.
✗ Branch 1284 not taken.
✗ Branch 1285 not taken.
✗ Branch 1286 not taken.
✗ Branch 1287 not taken.
✗ Branch 1288 not taken.
✗ Branch 1289 not taken.
✗ Branch 1290 not taken.
✗ Branch 1291 not taken.
✗ Branch 1292 not taken.
✗ Branch 1293 not taken.
✗ Branch 1294 not taken.
✗ Branch 1295 not taken.
✗ Branch 1296 not taken.
✗ Branch 1297 not taken.
✗ Branch 1298 not taken.
✗ Branch 1299 not taken.
✗ Branch 1300 not taken.
✗ Branch 1301 not taken.
✗ Branch 1302 not taken.
✗ Branch 1303 not taken.
✗ Branch 1304 not taken.
✗ Branch 1305 not taken.
✗ Branch 1306 not taken.
✗ Branch 1307 not taken.
✗ Branch 1308 not taken.
✗ Branch 1309 not taken.
✗ Branch 1310 not taken.
✗ Branch 1311 not taken.
✗ Branch 1312 not taken.
✗ Branch 1313 not taken.
✗ Branch 1314 not taken.
✗ Branch 1315 not taken.
✗ Branch 1316 not taken.
✗ Branch 1317 not taken.
✗ Branch 1318 not taken.
✗ Branch 1319 not taken.
✗ Branch 1320 not taken.
✗ Branch 1321 not taken.
✗ Branch 1322 not taken.
✗ Branch 1323 not taken.
✗ Branch 1324 not taken.
✗ Branch 1325 not taken.
✗ Branch 1326 not taken.
✗ Branch 1327 not taken.
✗ Branch 1328 not taken.
✗ Branch 1329 not taken.
✗ Branch 1330 not taken.
1399006681 switch(arg)
15939 {
15940 //debug ri->d[]
15941 case DEBUGD:
15942 {
15943 int32_t a = vbound((ri->d[rINDEX] / 10000), 0, 255);
15944 ri->d[a] = value/10000;
15945 break;
15946 }
15947
15948 ///----------------------------------------------------------------------------------------------------//
15949 //FFC Variables
15950 case DATA:
15951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272629 times.
2272629 if(BC::checkFFC(ri->ffcref, "ffc->Data") == SH::_NoError)
15952 {
15953 2272629 zc_ffc_set(tmpscr->ffcs[ri->ffcref], vbound(value/10000,0,MAXCOMBOS-1));
15954 2272629 }
15955 2272629 break;
15956
15957 case FFSCRIPT:
15958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9725 times.
9725 if(BC::checkFFC(ri->ffcref, "ffc->Script") == SH::_NoError)
15959 {
15960 9725 tmpscr->ffcs[ri->ffcref].script = vbound(value/10000, 0, NUMSCRIPTFFC-1);
15961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9725 times.
9725 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
15962 {
15963
2/2
✓ Branch 0 taken 19450 times.
✓ Branch 1 taken 9725 times.
29175 for(int32_t i=0; i<2; i++)
15964 19450 tmpscr->ffcs[ri->ffcref].inita[i] = 0;
15965
15966
2/2
✓ Branch 0 taken 77800 times.
✓ Branch 1 taken 9725 times.
87525 for(int32_t i=0; i<8; i++)
15967 77800 tmpscr->ffcs[ri->ffcref].initd[i] = 0;
15968 9725 }
15969
2/2
✓ Branch 0 taken 155600 times.
✓ Branch 1 taken 9725 times.
165325 for(int32_t i=0; i<16; i++)
15970 155600 ffmisc[ri->ffcref][i] = 0;
15971
15972 9725 auto& data = get_script_engine_data(ScriptType::FFC, ri->ffcref);
15973 9725 data.ref.Clear();
15974 9725 data.initialized = false;
15975 9725 FFScript::deallocateAllScriptOwned(ScriptType::FFC, ri->ffcref);
15976 9725 }
15977 9725 break;
15978
15979
15980 case FCSET:
15981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1042466 times.
1042466 if(BC::checkFFC(ri->ffcref, "ffc->CSet") == SH::_NoError)
15982 1042466 tmpscr->ffcs[ri->ffcref].cset = (value/10000)&15;
15983 1042466 break;
15984
15985 case DELAY:
15986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2881 times.
2881 if(BC::checkFFC(ri->ffcref, "ffc->Delay") == SH::_NoError)
15987 2881 tmpscr->ffcs[ri->ffcref].delay = value/10000;
15988 2881 break;
15989
15990 case FX:
15991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1215066 times.
1215066 if(BC::checkFFC(ri->ffcref, "ffc->X") == SH::_NoError)
15992 1215066 tmpscr->ffcs[ri->ffcref].x = zslongToFix(value);
15993 1215066 break;
15994
15995 case FY:
15996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1217071 times.
1217071 if(BC::checkFFC(ri->ffcref, "ffc->Y") == SH::_NoError)
15997 1217071 tmpscr->ffcs[ri->ffcref].y=zslongToFix(value);
15998 1217071 break;
15999
16000 case XD:
16001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9445 times.
9445 if(BC::checkFFC(ri->ffcref, "ffc->Vx") == SH::_NoError)
16002 9445 tmpscr->ffcs[ri->ffcref].vx=zslongToFix(value);
16003 9445 break;
16004
16005 case YD:
16006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9429 times.
9429 if(BC::checkFFC(ri->ffcref, "ffc->Vy") == SH::_NoError)
16007 9429 tmpscr->ffcs[ri->ffcref].vy=zslongToFix(value);
16008 9429 break;
16009
16010 case FFCID:
16011 break;
16012
16013 case XD2:
16014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9173 times.
9173 if(BC::checkFFC(ri->ffcref, "ffc->Ax") == SH::_NoError)
16015 9173 tmpscr->ffcs[ri->ffcref].ax=zslongToFix(value);
16016 9173 break;
16017
16018 case YD2:
16019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9173 times.
9173 if(BC::checkFFC(ri->ffcref, "ffc->Ay") == SH::_NoError)
16020 9173 tmpscr->ffcs[ri->ffcref].ay=zslongToFix(value);
16021 9173 break;
16022
16023 case FFFLAGSD:
16024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229040 times.
229040 if(BC::checkFFC(ri->ffcref, "ffc->Flags[]") == SH::_NoError)
16025 {
16026 229040 auto flag = 1<<((ri->d[rINDEX])/10000);
16027 229040 ffcdata& ff = tmpscr->ffcs[ri->ffcref];
16028
2/2
✓ Branch 0 taken 31751 times.
✓ Branch 1 taken 197289 times.
229040 SETFLAG(ff.flags, flag, value);
16029
4/4
✓ Branch 0 taken 225803 times.
✓ Branch 1 taken 3237 times.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 222396 times.
229040 if (flag == ffSOLID || flag == ffCHANGER)
16030 6644 ff.updateSolid();
16031 229040 }
16032 229040 break;
16033
16034 case FFCWIDTH:
16035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3248 times.
3248 if(BC::checkFFC(ri->ffcref, "ffc->EffectWidth") == SH::_NoError)
16036 3248 tmpscr->ffcs[ri->ffcref].hit_width = (value/10000);
16037 3248 break;
16038
16039 case FFCHEIGHT:
16040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3250 times.
3250 if(BC::checkFFC(ri->ffcref, "ffc->EffectHeight") == SH::_NoError)
16041 3250 tmpscr->ffcs[ri->ffcref].hit_height = (value/10000);
16042 3250 break;
16043
16044 case FFTWIDTH:
16045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9503 times.
9503 if(BC::checkFFC(ri->ffcref, "ffc->TileWidth") == SH::_NoError)
16046 9503 tmpscr->ffcs[ri->ffcref].txsz = vbound(value/10000, 1, 4);
16047 9503 break;
16048
16049 case FFTHEIGHT:
16050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9513 times.
9513 if(BC::checkFFC(ri->ffcref, "ffc->TileHeight") == SH::_NoError)
16051 9513 tmpscr->ffcs[ri->ffcref].tysz = vbound(value/10000, 1, 4);
16052 9513 break;
16053
16054 case FFLINK:
16055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 616 times.
616 if(BC::checkFFC(ri->ffcref, "ffc->Link") == SH::_NoError)
16056 616 (tmpscr->ffcs[ri->ffcref].link)=vbound(value/10000, 0, MAXFFCS); // Allow "ffc->Link = 0" to unlink ffc.
16057 //0 is none, setting this before made it impssible to clear it. -Z
16058 616 break;
16059
16060 case FFMISCD:
16061 {
16062 900 int32_t a = vbound(ri->d[rINDEX]/10000,0,15);
16063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(BC::checkFFC(ri->ffcref, "ffc->Misc[]")== SH::_NoError)
16064 900 ffmisc[ri->ffcref][a]=value;
16065 900 break;
16066 }
16067
16068 case FFINITDD:
16069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17707 times.
17707 if(BC::checkFFC(ri->ffcref, "ffc->InitD[]") == SH::_NoError)
16070 17707 (tmpscr->ffcs[ri->ffcref].initd[vbound(ri->d[rINDEX]/10000,0,7)])=value;
16071 17707 break;
16072
16073 case FFCLASTCHANGERX:
16074 if(BC::checkFFC(ri->ffcref, "ffc->LastChangerX") == SH::_NoError)
16075 ffposx[ri->ffcref]=vbound(zslongToFix(value).getInt(),-32768, 32767);
16076 break;
16077
16078 case FFCLASTCHANGERY:
16079 if(BC::checkFFC(ri->ffcref, "ffc->LastChangerY") == SH::_NoError)
16080 ffposy[ri->ffcref]=vbound(zslongToFix(value).getInt(),-32768, 32767);
16081 break;
16082
16083
16084
16085 ///----------------------------------------------------------------------------------------------------//
16086 //Hero's Variables
16087 case LINKX:
16088 {
16089
2/2
✓ Branch 0 taken 1210 times.
✓ Branch 1 taken 443391 times.
444601 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
16090 {
16091 1210 Hero.setXfix(zslongToFix(value));
16092 1210 }
16093 else
16094 {
16095 443391 Hero.setX(value/10000);
16096 }
16097 }
16098 444601 break;
16099
16100 case LINKCSET:
16101 {
16102 Hero.cs = value/10000;
16103 break;
16104 }
16105 case LINKY:
16106 {
16107
2/2
✓ Branch 0 taken 1071 times.
✓ Branch 1 taken 457869 times.
458940 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
16108 {
16109 1071 Hero.setYfix(zslongToFix(value));
16110 1071 }
16111 else
16112 {
16113 457869 Hero.setY(value/10000);
16114 }
16115 }
16116 458940 break;
16117
16118 case LINKZ:
16119 {
16120
2/2
✓ Branch 0 taken 2767 times.
✓ Branch 1 taken 2 times.
2769 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
16121 {
16122 2767 Hero.setZfix(zslongToFix(value));
16123 2767 }
16124 else
16125 {
16126 2 Hero.setZ(value/10000);
16127 }
16128 }
16129 2769 break;
16130
16131 case LINKJUMP:
16132 64379 Hero.setFall(zslongToFix(value) * -100);
16133 64379 break;
16134
16135 case HEROFAKEJUMP:
16136 Hero.setFakeFall(zslongToFix(value) * -100);
16137 break;
16138
16139 case LINKDIR:
16140 {
16141 //Hero->setDir() calls reset_hookshot(), which removes the sword sprite.. O_o
16142
3/4
✓ Branch 0 taken 93219 times.
✓ Branch 1 taken 475 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93219 times.
93694 if(Hero.getAction() == attacking || Hero.getAction() == sideswimattacking) Hero.dir = (value/10000);
16143 93219 else Hero.setDir(value/10000);
16144
16145 93694 break;
16146 }
16147
16148 case LINKHITDIR:
16149 Hero.setHitDir(value / 10000);
16150 break;
16151
16152 case LINKGRAVITY:
16153 if(value)
16154 Hero.moveflags |= FLAG_OBEYS_GRAV;
16155 else
16156 Hero.moveflags &= ~FLAG_OBEYS_GRAV;
16157 break;
16158
16159 case HERONOSTEPFORWARD:
16160 FFCore.nostepforward = ( (value) ? 1 : 0 );
16161 break;
16162
16163 case LINKHP:
16164
6/6
✓ Branch 0 taken 174180 times.
✓ Branch 1 taken 96373 times.
✓ Branch 2 taken 270405 times.
✓ Branch 3 taken 148 times.
✓ Branch 4 taken 174032 times.
✓ Branch 5 taken 96373 times.
270553 game->set_life(zc_max(0, zc_min(value/10000,game->get_maxlife())));
16165 270553 break;
16166
16167 case LINKMP:
16168
6/6
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 5753 times.
✓ Branch 2 taken 10400 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4647 times.
✓ Branch 5 taken 5753 times.
10415 game->set_magic(zc_max(0, zc_min(value/10000,game->get_maxmagic())));
16169 10415 break;
16170
16171 case LINKMAXHP:
16172 56 game->set_maxlife(value/10000);
16173 56 break;
16174
16175 case LINKMAXMP:
16176 game->set_maxmagic(value/10000);
16177 break;
16178
16179 case LINKACTION:
16180 {
16181 388 int32_t act = value / 10000;
16182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
388 switch(act)
16183 {
16184 case hookshotout:
16185 case stunned:
16186 case ispushing:
16187 FFCore.setHeroAction(act);
16188 break;
16189 default:
16190 388 Hero.setAction((actiontype)(act));
16191 388 }
16192 //Protect from writing illegal actions to Hero's raw variable.
16193 //in the future, we can move all scripted actions that are not possible
16194 //to set in ZC into this mechanic. -Z
16195 388 break;
16196 }
16197
16198 case HEROHEALTHBEEP:
16199 {
16200 int32_t beep = vbound((value/10000),-4, 255);
16201 //-2 suspends system control of stopping the sound
16202 //-3 suspends system control of stopping the sound AND suspends
16203 // system control over starting or playing it.
16204 heart_beep_timer = beep;
16205 if ( heart_beep_timer > -1 )
16206 {
16207 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
16208 }
16209 else
16210 {
16211 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
16212 }
16213 break;
16214 }
16215
16216 case LINKHELD:
16217 Hero.setHeldItem(vbound(value/10000,0,MAXITEMS-1));
16218 break;
16219
16220 case HEROSTEPS:
16221 {
16222 lsteps[vbound(ri->d[rINDEX]/10000,0,7)] = value/10000;
16223 break;
16224 }
16225
16226 case HEROSTEPRATE:
16227 if(!get_qr(qr_NEW_HERO_MOVEMENT))
16228 {
16229 Z_scripterrlog("To use '%s', you must %s the quest rule '%s'.", "Hero->Step", "enable", "New Player Movement");
16230 }
16231 Hero.setStepRate(zc_max(value/10000,0));
16232 if(!get_qr(qr_SCRIPT_WRITING_HEROSTEP_DOESNT_CARRY_OVER))
16233 zinit.heroStep = Hero.getStepRate();
16234 break;
16235 case HEROSHOVEOFFSET:
16236 if(!get_qr(qr_NEW_HERO_MOVEMENT2))
16237 Z_scripterrlog("To use 'Hero->ShoveOffset', you must enable the quest rule 'Newer Player Movement'.");
16238 Hero.shove_offset = vbound(zslongToFix(value),16_zf,0_zf);
16239 if(!get_qr(qr_SCRIPT_WRITING_HEROSTEP_DOESNT_CARRY_OVER))
16240 zinit.shove_offset = Hero.shove_offset;
16241 break;
16242
16243 case LINKITEMD:
16244 {
16245 5906 int32_t itemID=vbound(ri->d[rINDEX]/10000,0,MAXITEMS-1);
16246
16247 // If the Cane of Byrna is being removed, cancel its effect.
16248
3/4
✓ Branch 0 taken 3219 times.
✓ Branch 1 taken 2687 times.
✓ Branch 2 taken 3219 times.
✗ Branch 3 not taken.
5906 if(value==0 && itemID==current_item_id(itype_cbyrna))
16249 stopCaneOfByrna();
16250
16251 5906 auto& data = get_script_engine_data(ScriptType::Item, itemID);
16252
16253 //Stop current script if set false.
16254
4/4
✓ Branch 0 taken 3219 times.
✓ Branch 1 taken 2687 times.
✓ Branch 2 taken 3203 times.
✓ Branch 3 taken 16 times.
5906 if ( !value && data.doscript )
16255 {
16256 16 data.doscript = 4; //Val of 4 means 'clear stack and quit'
16257 //itemScriptData[itemID].Clear(); //Don't clear here, causes crash if is current item!
16258 16 }
16259
4/4
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 3203 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 2645 times.
5890 else if ( value && !data.doscript )
16260 {
16261 //Clear the item refInfo and stack for use.
16262 2645 data.ref.Clear();
16263
1/2
✓ Branch 0 taken 2645 times.
✗ Branch 1 not taken.
2645 if ( (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) ) data.doscript = 1;
16264 2645 }
16265
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 3203 times.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
3245 else if ( value && data.doscript == 4 )
16266 {
16267 // Arbitrary event number 49326: Writing the item false, then true, in the same frame. -Z
16268 if ( (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) ) data.doscript = 1;
16269 }
16270
16271 5906 bool settrue = ( value != 0 );
16272
16273 //Sanity check to prevent setting the item if the value would be the same. -Z
16274
2/2
✓ Branch 0 taken 3834 times.
✓ Branch 1 taken 2072 times.
5906 if ( game->item[itemID] != settrue )
16275 {
16276 2072 game->set_item(itemID,(value != 0));
16277 2072 }
16278
16279
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5906 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5906 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
16280 {
16281 5906 ringcolor(false);
16282 //refreshpal=true;
16283 5906 }
16284
2/2
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 3219 times.
5906 if ( !value ) //setting the item false clears the state of forced ->Equipment writes.
16285 {
16286
1/2
✓ Branch 0 taken 3219 times.
✗ Branch 1 not taken.
3219 if ( game->forced_bwpn == itemID )
16287 {
16288 game->forced_bwpn = -1;
16289 } //not else if! -Z
16290
2/2
✓ Branch 0 taken 3218 times.
✓ Branch 1 taken 1 times.
3219 if ( game->forced_awpn == itemID )
16291 {
16292 1 game->forced_awpn = -1;
16293 1 }
16294
2/2
✓ Branch 0 taken 3216 times.
✓ Branch 1 taken 3 times.
3219 if ( game->forced_xwpn == itemID )
16295 {
16296 3 game->forced_xwpn = -1;
16297 3 }
16298
2/2
✓ Branch 0 taken 3216 times.
✓ Branch 1 taken 3 times.
3219 if ( game->forced_ywpn == itemID )
16299 {
16300 3 game->forced_ywpn = -1;
16301 3 }
16302 3219 }
16303 }
16304 5906 break;
16305
16306 case LINKEQUIP:
16307 {
16308 if ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) < 33 )
16309 {
16310 break;
16311 }
16312 //int32_t seta = (value/10000) >> 8; int32_t setb = value/10000) & 0xFF;
16313 int32_t setb = ((value/10000)&0xFF00)>>8, seta = (value/10000)&0xFF;
16314 seta = vbound(seta,-1,255);
16315 setb = vbound(setb,-1,255);
16316 //zprint("A is: %d\n", seta);
16317 //zprint("A is: %d\n", setb);
16318
16319 Awpn = seta;
16320 game->awpn = 255;
16321 game->forced_awpn = seta;
16322 game->items_off[seta] = 0;
16323 directItemA = seta;
16324
16325 Bwpn = setb;
16326 game->bwpn = 255;
16327 game->forced_bwpn = setb;
16328 game->items_off[setb] = 0;
16329 directItemB = setb;
16330 break;
16331 }
16332
16333
16334 case SETITEMSLOT:
16335 {
16336 //ri->d[rINDEX2] = 1st arg
16337 //ri->d[rINDEX] = 2nd arg
16338 //value = third arg
16339 //int32_t item, int32_t slot, int32_t force
16340 int32_t itm = ri->d[rINDEX]/10000;
16341 itm = vbound(itm, -1, 255);
16342
16343 int32_t slot = ri->d[rINDEX2]/10000;
16344 int32_t force = ri->d[rEXP1]/10000;
16345
16346 zprint("SetItemSlot rid->[0] is (%i), trying to use for '%s'\n", itm, "itm");
16347 zprint("SetItemSlot rid->[1] is (%i), trying to use for '%s'\n", slot, "slot");
16348 zprint("SetItemSlot rid->[2] is (%i), trying to use for '%s'\n", force, "force");
16349
16350 //If we add more item buttons, slot should be an int32_t
16351 //and force shuld be an int32_t
16352
16353 /*
16354 For zScript,
16355 const int32_t ITM_REQUIRE_NONE = 0
16356 const int32_t ITM_REQUIRE_INVENTORY = 1
16357 const int32_t ITM_REQUIRE_A_SLOT_RULE = 2
16358 //Combine as flags
16359 */
16360 if ( force == 0 )
16361 {
16362 switch(slot)
16363 {
16364 case 0: //b
16365 Bwpn = itm;
16366 game->items_off[itm] = 0;
16367 game->bwpn = 255;
16368 game->forced_bwpn = itm;
16369 directItemB = itm;
16370 break;
16371
16372 case 1: //a
16373 Awpn = itm;
16374 game->items_off[itm] = 0;
16375 game->awpn = 255;
16376 game->forced_awpn = itm;
16377 directItemA = itm;
16378 break;
16379
16380 case 2: //x
16381 Xwpn = itm;
16382 game->items_off[itm] = 0;
16383 game->xwpn = 255;
16384 game->forced_xwpn = itm;
16385 directItemX = itm;
16386 break;
16387
16388 case 3: //y
16389 Ywpn = itm;
16390 game->items_off[itm] = 0;
16391 game->ywpn = 255;
16392 game->forced_ywpn = itm;
16393 directItemX = itm;
16394 break;
16395 }
16396 }
16397 else if ( force == 1 )
16398 {
16399 if (game->item[itm])
16400 {
16401 switch(slot)
16402 {
16403 case 0: //b
16404 Bwpn = itm;
16405 game->items_off[itm] = 0;
16406 game->bwpn = 255;
16407 game->forced_bwpn = itm;
16408 directItemB = itm;
16409 break;
16410
16411 case 1: //a
16412 Awpn = itm;
16413 game->items_off[itm] = 0;
16414 game->awpn = 255;
16415 game->forced_awpn = itm;
16416 directItemA = itm;
16417 break;
16418
16419 case 2: //x
16420 Xwpn = itm;
16421 game->items_off[itm] = 0;
16422 game->xwpn = 255;
16423 game->forced_xwpn = itm;
16424 directItemX = itm;
16425 break;
16426
16427 case 3: //y
16428 Ywpn = itm;
16429 game->items_off[itm] = 0;
16430 game->ywpn = 255;
16431 game->forced_ywpn = itm;
16432 directItemY = itm;
16433 break;
16434 }
16435 }
16436 }
16437 else if ( force == 2 )
16438 {
16439 switch(slot)
16440 {
16441 case 0: //b
16442 Bwpn = itm;
16443 game->items_off[itm] = 0;
16444 game->bwpn = 255;
16445 game->forced_bwpn = itm;
16446 directItemB = itm;
16447 break;
16448
16449 case 1: //a
16450 if (get_qr(qr_SELECTAWPN))
16451 {
16452 Awpn = itm;
16453 game->items_off[itm] = 0;
16454 game->awpn = 255;
16455 game->forced_awpn = itm;
16456 directItemA = itm;
16457 }
16458 break;
16459
16460 case 2: //x
16461 Xwpn = itm;
16462 game->items_off[itm] = 0;
16463 game->xwpn = 255;
16464 game->forced_xwpn = itm;
16465 directItemX = itm;
16466 break;
16467
16468 case 3: //y
16469 Ywpn = itm;
16470 game->items_off[itm] = 0;
16471 game->ywpn = 255;
16472 game->forced_ywpn = itm;
16473 directItemY = itm;
16474 break;
16475 }
16476 }
16477 else if ( force == 3 ) //Flag ITM_REQUIRE_INVENTORY + ITM_REQUIRE_SLOT_A_RULE
16478 {
16479 if ( game->item[itm] )
16480 {
16481 switch(slot)
16482 {
16483 case 0: //b
16484 Bwpn = itm;
16485 game->items_off[itm] = 0;
16486 game->bwpn = 255;
16487 game->forced_bwpn = itm;
16488 directItemB = itm;
16489 break;
16490
16491 case 1: //a
16492 if (get_qr(qr_SELECTAWPN))
16493 {
16494 Awpn = itm;
16495 game->items_off[itm] = 0;
16496 game->awpn = 255;
16497 game->forced_awpn = itm;
16498 directItemA = itm;
16499 }
16500 break;
16501
16502 case 2: //x
16503 Xwpn = itm;
16504 game->items_off[itm] = 0;
16505 game->xwpn = 255;
16506 game->forced_xwpn = itm;
16507 directItemX = itm;
16508 break;
16509
16510 case 3: //y
16511 Ywpn = itm;
16512 game->items_off[itm] = 0;
16513 game->ywpn = 255;
16514 game->forced_ywpn = itm;
16515 directItemY = itm;
16516 break;
16517 }
16518 }
16519 }
16520 }
16521 break;
16522
16523 case LINKINVIS:
16524 740 Hero.setDontDraw((value ? 2 : 0));
16525 740 break;
16526
16527 case LINKINVINC:
16528 1532 Hero.scriptcoldet=(value/10000);
16529 1532 break;
16530
16531 case LINKENGINEANIMATE:
16532 Hero.do_animation=(value ? 1 : 0);
16533 break;
16534
16535 case LINKSWORDJINX:
16536 4 Hero.setSwordClk(value/10000);
16537 4 break;
16538
16539 case LINKITEMJINX:
16540 5161 Hero.setItemClk(value/10000);
16541 5161 break;
16542
16543 case LINKDRUNK:
16544 Hero.setDrunkClock(value/10000);
16545 break;
16546
16547 case LINKMISCD:
16548 56626 Hero.miscellaneous[vbound(ri->d[rINDEX]/10000,0,31)] = value;
16549 56626 break;
16550
16551 case LINKHITBY:
16552 {
16553 int32_t indx = ri->d[rINDEX]/10000;
16554 switch(indx)
16555 {
16556 //screen index objects
16557 case 0:
16558 case 1:
16559 case 2:
16560 case 3:
16561 case 8:
16562 case 9:
16563 case 10:
16564 case 11:
16565 case 12:
16566 case 16:
16567 {
16568 Hero.sethitHeroUID(indx, (value/10000)); //Why the Flidd did I vbound this? UIDs are LONGs, with a starting value of 0.0001. Why did I allow it, in fact? -Z
16569 break;
16570 }
16571 //UIDs
16572 case 4:
16573 case 5:
16574 case 6:
16575 case 7:
16576 case 13:
16577 case 14:
16578 case 15:
16579 {
16580 Hero.sethitHeroUID(indx, value); //Why the Flidd did I vbound this? UIDs are LONGs, with a starting value of 0.0001. Why did I allow it, in fact? -Z
16581 break;
16582 }
16583 default: { al_trace("Invalid index passed to Player->HitBy[%d] /n", indx); break; }
16584 }
16585 break;
16586 }
16587
16588 case LINKDEFENCE:
16589 Hero.set_defence(vbound(ri->d[rINDEX]/10000,0,255), ((char)vbound((value/10000), 0, 255)));
16590 break;
16591
16592 case LINKHXOFS:
16593 (Hero.hxofs)=(zfix)(value/10000);
16594 break;
16595
16596 case LINKROTATION:
16597 if ( get_qr(qr_OLDSPRITEDRAWS) )
16598 {
16599 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
16600 "Player->Rotation");
16601 break;
16602 }
16603 (Hero.rotation)=(value/10000);
16604 break;
16605
16606 case LINKSCALE:
16607 {
16608 if ( get_qr(qr_OLDSPRITEDRAWS) )
16609 {
16610 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
16611 "Player->Scale");
16612 break;
16613 }
16614 (Hero.scale)=(value/100.0);
16615 //al_trace("Player.scale is: %d\n", Hero.scale);
16616 //al_trace("Trying to set Player.scale to: %d\n", value/100.0);
16617 break;
16618 }
16619
16620 case LINKHYOFS:
16621 (Hero.hyofs)=(zfix)(value/10000);
16622 break;
16623
16624 case LINKXOFS:
16625 (Hero.xofs)=(zfix)(value/10000);
16626 break;
16627
16628 case LINKYOFS:
16629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280560 times.
280560 (Hero.yofs)=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16630 280560 break;
16631 case HEROTOTALDYOFFS:
16632 break; //READ-ONLY
16633
16634 case HEROSHADOWXOFS:
16635 (Hero.shadowxofs)=(zfix)(value/10000);
16636 break;
16637
16638 case HEROSHADOWYOFS:
16639 (Hero.shadowyofs)=(zfix)(value/10000);
16640 break;
16641
16642 case LINKZOFS:
16643 (Hero.zofs)=(zfix)(value/10000);
16644 break;
16645
16646 case LINKHXSZ:
16647 (Hero.hit_width)=(zfix)(value/10000);
16648 break;
16649
16650 case LINKHYSZ:
16651 (Hero.hit_height)=(zfix)(value/10000);
16652 break;
16653
16654 case LINKHZSZ:
16655 (Hero.hzsz)=(zfix)(value/10000);
16656 break;
16657
16658 case LINKTXSZ:
16659 (Hero.txsz)=(zfix)(value/10000);
16660 break;
16661
16662 case LINKTYSZ:
16663 (Hero.tysz)=(zfix)(value/10000);
16664 break;
16665
16666 case LINKTILE:
16667 (Hero.tile)=(zfix)(value/10000);
16668 break;
16669
16670 case LINKFLIP:
16671 (Hero.flip)=(zfix)(value/10000);
16672 break;
16673
16674
16675
16676 case LINKINVFRAME:
16677 Hero.setHClk( (int32_t)vbound((value/10000), 0, 214747) );
16678 break;
16679
16680 case LINKCANFLICKER:
16681 Hero.setCanFlicker((value/10000)?1:0);
16682 break;
16683
16684 case LINKHURTSFX:
16685 Hero.setHurtSFX( (int32_t)vbound((value/10000), 0, 255) );
16686 break;
16687
16688
16689 case LINKITEMB:
16690 {
16691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93758 times.
93758 if ( value/10000 < -1 )
16692 {
16693 al_trace("Tried to write an invalid item ID to Player->ItemB: %d\n",value/10000);
16694 break;
16695 }
16696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93758 times.
93758 if ( value/10000 > MAXITEMS-1 )
16697 {
16698 al_trace("Tried to write an invalid item ID to Player->ItemB: %d\n",value/10000);
16699 break;
16700 }
16701 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
16702
16703
2/2
✓ Branch 0 taken 93750 times.
✓ Branch 1 taken 8 times.
93758 if (Bwpn != (value/10000))
16704 {
16705 8 Bwpn = value/10000;
16706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(new_subscreen_active)
16707 8 new_subscreen_active->get_page_pos(Bwpn, game->bwpn);
16708 8 game->forced_bwpn = value/10000;
16709 8 game->items_off[value/10000] = 0;
16710 8 }
16711 93758 directItemB = value/10000;
16712 93758 break;
16713 }
16714
16715
16716 case LINKITEMA:
16717 {
16718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93759 times.
93759 if ( value/10000 < -1 )
16719 {
16720 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemA: %d\n",value/10000);
16721 break;
16722 }
16723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93759 times.
93759 if ( value/10000 > MAXITEMS-1 )
16724 {
16725 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemA: %d\n",value/10000);
16726 break;
16727 }
16728 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
16729
2/2
✓ Branch 0 taken 93752 times.
✓ Branch 1 taken 7 times.
93759 if (Awpn != (value/10000))
16730 {
16731 7 Awpn = value/10000;
16732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(new_subscreen_active)
16733 7 new_subscreen_active->get_page_pos(Awpn, game->awpn);
16734 7 game->items_off[value/10000] = 0;
16735 7 game->forced_awpn = value/10000;
16736 7 }
16737 93759 directItemA = value/10000;
16738 93759 break;
16739 }
16740
16741 case LINKITEMX:
16742 {
16743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93772 times.
93772 if ( value/10000 < -1 )
16744 {
16745 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemX: %d\n",value/10000);
16746 break;
16747 }
16748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93772 times.
93772 if ( value/10000 > MAXITEMS-1 )
16749 {
16750 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemX: %d\n",value/10000);
16751 break;
16752 }
16753 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
16754
2/2
✓ Branch 0 taken 93739 times.
✓ Branch 1 taken 33 times.
93772 if (Xwpn != (value/10000))
16755 {
16756 33 Xwpn = value/10000;
16757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(new_subscreen_active)
16758 33 new_subscreen_active->get_page_pos(Xwpn, game->xwpn);
16759 33 game->items_off[value/10000] = 0;
16760 33 game->forced_xwpn = value/10000;
16761 33 }
16762 93772 directItemX = value/10000;
16763 93772 break;
16764 }
16765 case LINKITEMY:
16766 {
16767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93778 times.
93778 if ( value/10000 < -1 )
16768 {
16769 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemY: %d\n",value/10000);
16770 break;
16771 }
16772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93778 times.
93778 if ( value/10000 > MAXITEMS-1 )
16773 {
16774 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemY: %d\n",value/10000);
16775 break;
16776 }
16777 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
16778
2/2
✓ Branch 0 taken 93735 times.
✓ Branch 1 taken 43 times.
93778 if (Ywpn != (value/10000))
16779 {
16780 43 Ywpn = value/10000;
16781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(new_subscreen_active)
16782 43 new_subscreen_active->get_page_pos(Ywpn, game->ywpn);
16783 43 game->items_off[value/10000] = 0;
16784 43 game->forced_ywpn = value/10000;
16785 43 }
16786 93778 directItemY = value/10000;
16787 93778 break;
16788 }
16789
16790
16791 case LINKEATEN:
16792 Hero.setEaten(value/10000);
16793 break;
16794 case LINKGRABBED:
16795 Hero.inwallm = value != 0;
16796 break;
16797 case HEROBUNNY:
16798 Hero.setBunnyClock(value/10000);
16799 break;
16800 case LINKPUSH:
16801 Hero.pushing = zc_max((value/10000),0);
16802 break;
16803 case LINKSTUN:
16804 Hero.setStunClock(value/10000);
16805 break;
16806 case LINKSCRIPTTILE:
16807 2569 script_hero_sprite=vbound((value/10000), -1, NEWMAXTILES-1);
16808 2569 break;
16809
16810 case HEROSCRIPTCSET:
16811 script_hero_cset=vbound((value/10000), -1, 0xF);
16812 break;
16813 case LINKSCRIPFLIP:
16814 2569 script_hero_flip=vbound((value/10000),-1,256);
16815 2569 break;
16816
16817 case GAMESETA:
16818 {
16819 //int32_t state = (ri->d[rINDEX2]/10000);
16820 //int32_t extend = (ri->d[rINDEX2]/10000);
16821 //int32_t dir = (ri->d[rINDEX]/10000);
16822 // Z_message("Trying to force-set the A-button item().\n");
16823 // Hero.setAButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
16824 }
16825 break;
16826
16827 case GAMESETB:
16828 {
16829 //int32_t state = (ri->d[rINDEX2]/10000);
16830 //int32_t extend = (ri->d[rINDEX2]/10000);
16831 //int32_t dir = (ri->d[rINDEX]/10000);
16832 // Z_message("Trying to force-set the A-button item().\n");
16833 // Hero.setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
16834 }
16835 break;
16836
16837 //Set Hero Diagonal
16838 case LINKDIAG:
16839 Hero.setDiagMove(value?1:0);
16840 set_qr(qr_LTTPWALK, value?1:0);
16841 break;
16842
16843 //Set Hero Big Hitbox
16844 case LINKBIGHITBOX:
16845 Hero.setBigHitbox((value/10000)?1:0);
16846 set_qr(qr_LTTPCOLLISION, (value/10000)?1:0);
16847 break;
16848
16849 case LINKCLIMBING:
16850 Hero.setOnSideviewLadder(value!=0?true:false);
16851 break;
16852
16853 case HEROJUMPCOUNT:
16854 Hero.extra_jump_count = value/10000;
16855 break;
16856
16857 case HEROPULLCLK:
16858 Hero.pit_pullclk = value/10000;
16859 break;
16860 case HEROFALLCLK:
16861 {
16862 int32_t val = vbound(value/10000,0,70);
16863 if(val)
16864 Hero.setAction(falling);
16865 else if(Hero.action == falling)
16866 {
16867 Hero.setAction(none);
16868 }
16869 Hero.fallclk = val;
16870 break;
16871 }
16872 case HEROFALLCMB:
16873 Hero.fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
16874 break;
16875 case HERODROWNCLK:
16876 {
16877 int32_t val = vbound(value/10000,0,70);
16878 if(val)
16879 {
16880 if (Hero.action != lavadrowning) Hero.setAction(drowning);
16881 }
16882 else if(Hero.action == drowning || Hero.action == lavadrowning)
16883 {
16884 Hero.setAction(none);
16885 }
16886 Hero.drownclk = val;
16887 break;
16888 }
16889 case HERODROWNCMB:
16890 Hero.drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
16891 break;
16892 case HEROFAKEZ:
16893 {
16894 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
16895 {
16896 Hero.setFakeZfix(zslongToFix(value));
16897 }
16898 else
16899 {
16900 Hero.setFakeZ(value/10000);
16901 }
16902 }
16903 break;
16904 case HEROMOVEFLAGS:
16905 {
16906 166 int32_t indx = ri->d[rINDEX]/10000;
16907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 if(BC::checkBounds(indx, 0, 10, "Hero->MoveFlags[]") == SH::_NoError)
16908 {
16909 //All bits, in order, of a single byte; just use bitwise
16910 166 int32_t bit = 1<<indx;
16911
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 165 times.
166 if(value)
16912 1 Hero.moveflags |= bit;
16913 else
16914 165 Hero.moveflags &= ~bit;
16915 166 }
16916 166 break;
16917 }
16918 case HEROLIFTFLAGS:
16919 {
16920 int32_t indx = ri->d[rINDEX]/10000;
16921 if(BC::checkBounds(indx, 0, NUM_LIFTFL-1, "Hero->LiftFlags[]") == SH::_NoError)
16922 {
16923 int32_t bit = 1<<indx;
16924 if(value)
16925 Hero.liftflags |= bit;
16926 else
16927 Hero.liftflags &= ~bit;
16928 }
16929 break;
16930 }
16931
16932 case HEROSHIELDJINX:
16933 Hero.shieldjinxclk = value/10000;
16934 break;
16935
16936 case CLOCKACTIVE:
16937 {
16938 Hero.setClock(watch=(value?true:false));
16939 break;
16940 }
16941
16942 case CLOCKCLK:
16943 clockclk = vbound((value/10000), 0, 214748);
16944 break;
16945
16946 case HERORESPAWNX:
16947 {
16948 zfix zx = zslongToFix(value);
16949 Hero.respawn_x = vbound(zx, 0_zf, 240_zf);
16950 break;
16951 }
16952
16953 case HERORESPAWNY:
16954 {
16955 zfix zy = zslongToFix(value);
16956 Hero.respawn_y = vbound(zy, 0_zf, 160_zf);
16957 break;
16958 }
16959
16960 case HERORESPAWNDMAP:
16961 {
16962 Hero.respawn_dmap = vbound(value/10000, 0, MAXDMAPS-1);
16963 break;
16964 }
16965
16966 case HERORESPAWNSCR:
16967 {
16968 Hero.respawn_scr = vbound(value/10000, 0, 0x7F);
16969 break;
16970 }
16971
16972
16973 case HEROSWITCHMAXTIMER:
16974 case HEROSWITCHTIMER:
16975 break; //read-only
16976
16977 case HEROIMMORTAL:
16978 {
16979 Hero.setImmortal(value/10000);
16980 break;
16981 }
16982
16983 case HEROCOYOTETIME:
16984 {
16985 auto v = value/10000;
16986 if(v < 0 || v > 65535) v = 65535;
16987 Hero.coyotetime = word(v);
16988 break;
16989 }
16990 case HEROLIFTEDWPN:
16991 {
16992 if(Hero.lift_wpn)
16993 {
16994 delete Hero.lift_wpn;
16995 Hero.lift_wpn = nullptr;
16996 }
16997 if(value)
16998 {
16999 if(weapon* wpn = checkLWpn(value,"Hero->LiftedWeapon"))
17000 {
17001 if(wpn == Hero.lift_wpn) break;
17002 Hero.lift_wpn = wpn;
17003 if(Lwpns.find(wpn) > -1)
17004 Lwpns.remove(wpn);
17005 if(curScriptType == ScriptType::Lwpn && value == curScriptIndex)
17006 earlyretval = RUNSCRIPT_SELFREMOVE;
17007 }
17008 }
17009 break;
17010 }
17011 case HEROLIFTTIMER:
17012 {
17013 Hero.liftclk = value/10000;
17014 break;
17015 }
17016 case HEROLIFTMAXTIMER:
17017 {
17018 Hero.tliftclk = value/10000;
17019 break;
17020 }
17021 case HEROLIFTHEIGHT:
17022 {
17023 Hero.liftheight = zslongToFix(value);
17024 break;
17025 }
17026 case HEROHAMMERSTATE:
17027 {
17028 //readonly
17029 break;
17030 }
17031
17032
17033 ///----------------------------------------------------------------------------------------------------//
17034 //Input States
17035 case INPUTSTART:
17036 {
17037 928305 control_state[6]=(value?true:false);
17038
2/2
✓ Branch 0 taken 928224 times.
✓ Branch 1 taken 81 times.
928305 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[6]=false;
17039 928305 break;
17040 }
17041
17042 case INPUTMAP:
17043 {
17044 461890 control_state[9]=(value?true:false);
17045
2/2
✓ Branch 0 taken 461809 times.
✓ Branch 1 taken 81 times.
461890 if ( get_qr(qr_FIXDRUNKINPUTS) )
17046 81 drunk_toggle_state[9]=false;
17047 461890 break;
17048 }
17049
17050 case INPUTUP:
17051 {
17052 249228 control_state[0]=(value?true:false);
17053
2/2
✓ Branch 0 taken 248029 times.
✓ Branch 1 taken 1199 times.
249228 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[0]=false;
17054 249228 break;
17055 }
17056
17057 case INPUTDOWN:
17058 {
17059 249220 control_state[1]=(value?true:false);
17060
2/2
✓ Branch 0 taken 248027 times.
✓ Branch 1 taken 1193 times.
249220 if ( get_qr(qr_FIXDRUNKINPUTS) )
17061 1193 drunk_toggle_state[1]=false;
17062 249220 break;
17063 }
17064
17065 case INPUTLEFT:
17066 {
17067 236658 control_state[2]=(value?true:false);
17068
2/2
✓ Branch 0 taken 235481 times.
✓ Branch 1 taken 1177 times.
236658 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[2]=false;
17069 236658 break;
17070 }
17071
17072 case INPUTRIGHT:
17073 {
17074 236880 control_state[3]=(value?true:false);
17075
2/2
✓ Branch 0 taken 235703 times.
✓ Branch 1 taken 1177 times.
236880 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[3]=false;
17076 236880 break;
17077 }
17078
17079 case INPUTA:
17080 {
17081 89166 control_state[4]=(value?true:false);
17082
2/2
✓ Branch 0 taken 89113 times.
✓ Branch 1 taken 53 times.
89166 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[4]=false;
17083 89166 break;
17084 }
17085
17086 case INPUTB:
17087 {
17088 76223 control_state[5]=(value?true:false);
17089
1/2
✓ Branch 0 taken 76223 times.
✗ Branch 1 not taken.
76223 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[5]=false;
17090 76223 break;
17091 }
17092
17093 case INPUTL:
17094 {
17095 78737 control_state[7]=(value?true:false);
17096
2/2
✓ Branch 0 taken 78656 times.
✓ Branch 1 taken 81 times.
78737 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[7]=false;
17097 78737 break;
17098 }
17099
17100 case INPUTR:
17101 {
17102 78784 control_state[8]=(value?true:false);
17103
2/2
✓ Branch 0 taken 78703 times.
✓ Branch 1 taken 81 times.
78784 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[8]=false;
17104 78784 break;
17105 }
17106
17107 case INPUTEX1:
17108 {
17109 222649 control_state[10]=(value?true:false);
17110 222649 break;
17111 }
17112
17113 case INPUTEX2:
17114 222649 control_state[11]=(value?true:false);
17115 222649 break;
17116
17117 case INPUTEX3:
17118 222649 control_state[12]=(value?true:false);
17119 222649 break;
17120
17121 case INPUTEX4:
17122 222649 control_state[13]=(value?true:false);
17123 222649 break;
17124
17125 case INPUTAXISUP:
17126 control_state[14]=(value?true:false);
17127 break;
17128
17129 case INPUTAXISDOWN:
17130 control_state[15]=(value?true:false);
17131 break;
17132
17133 case INPUTAXISLEFT:
17134 control_state[16]=(value?true:false);
17135 break;
17136
17137 case INPUTAXISRIGHT:
17138 control_state[17]=(value?true:false);
17139 break;
17140
17141 case INPUTPRESSSTART:
17142 928305 button_press[6]=(value?true:false);
17143 928305 break;
17144
17145 case INPUTPRESSMAP:
17146 461890 button_press[9]=(value?true:false);
17147 461890 break;
17148
17149 case INPUTPRESSUP:
17150 218369 button_press[0]=(value?true:false);
17151 218369 break;
17152
17153 case INPUTPRESSDOWN:
17154 218364 button_press[1]=(value?true:false);
17155 218364 break;
17156
17157 case INPUTPRESSLEFT:
17158 218431 button_press[2]=(value?true:false);
17159 218431 break;
17160
17161 case INPUTPRESSRIGHT:
17162 218461 button_press[3]=(value?true:false);
17163 218461 break;
17164
17165 case INPUTPRESSA:
17166 83086 button_press[4]=(value?true:false);
17167 83086 break;
17168
17169 case INPUTPRESSB:
17170 70141 button_press[5]=(value?true:false);
17171 70141 break;
17172
17173 case INPUTPRESSL:
17174 75869 button_press[7]=(value?true:false);
17175 75869 break;
17176
17177 case INPUTPRESSR:
17178 75916 button_press[8]=(value?true:false);
17179 75916 break;
17180
17181 case INPUTPRESSEX1:
17182 222649 button_press[10]=(value?true:false);
17183 222649 break;
17184
17185 case INPUTPRESSEX2:
17186 222649 button_press[11]=(value?true:false);
17187 222649 break;
17188
17189 case INPUTPRESSEX3:
17190 222649 button_press[12]=(value?true:false);
17191 222649 break;
17192
17193 case INPUTPRESSEX4:
17194 222649 button_press[13]=(value?true:false);
17195 222649 break;
17196
17197 case INPUTPRESSAXISUP:
17198 button_press[14]=(value?true:false);
17199 break;
17200
17201 case INPUTPRESSAXISDOWN:
17202 button_press[15]=(value?true:false);
17203 break;
17204
17205 case INPUTPRESSAXISLEFT:
17206 button_press[16]=(value?true:false);
17207 break;
17208
17209 case INPUTPRESSAXISRIGHT:
17210 button_press[17]=(value?true:false);
17211 break;
17212
17213 case INPUTMOUSEX:
17214 {
17215 auto [x, y] = rti_game.local_to_world(value/10000, mouse_y);
17216 position_mouse(x, y);
17217 break;
17218 }
17219
17220 case INPUTMOUSEY:
17221 {
17222 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
17223 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset : (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17224 auto [x, y] = rti_game.local_to_world(mouse_x, value/10000 + tempoffset);
17225 position_mouse(x, y);
17226 break;
17227 }
17228
17229 case INPUTMOUSEZ:
17230 position_mouse_z(value/10000);
17231 break;
17232
17233 case FFRULE:
17234 {
17235 int32_t ruleid = vbound((ri->d[rINDEX]/10000),0,qr_MAX);
17236 set_qr(ruleid, (value?true:false));
17237 switch(ruleid)
17238 {
17239 case qr_LTTPWALK:
17240 Hero.setDiagMove(value?1:0);
17241 break;
17242 case qr_LTTPCOLLISION:
17243 Hero.setBigHitbox(value?1:0);
17244 break;
17245 case qr_ZS_NO_NEG_ARRAY:
17246 can_neg_array = !value;
17247 break;
17248 }
17249 }
17250 break;
17251
17252 case BUTTONPRESS:
17253 // DUkey, DDkey, DLkey, DRkey, Akey, Bkey, Skey, Lkey, Rkey, Pkey, Exkey1, Exkey2, Exkey3, Exkey4 };
17254 {
17255 //Read-only
17256 281176 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
17257 281176 button_press[button]=(value?true:false);
17258
4/4
✓ Branch 0 taken 220924 times.
✓ Branch 1 taken 60252 times.
✓ Branch 2 taken 42471 times.
✓ Branch 3 taken 178453 times.
281176 if ( button < 11 && get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[button]=false;
17259
17260 }
17261 281176 break;
17262
17263 case BUTTONINPUT:
17264 {
17265 //Read-only
17266 281262 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
17267 281262 control_state[button]=(value?true:false);
17268
4/4
✓ Branch 0 taken 221010 times.
✓ Branch 1 taken 60252 times.
✓ Branch 2 taken 42557 times.
✓ Branch 3 taken 178453 times.
281262 if ( button < 11 && get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[button]=false;
17269 }
17270 281262 break;
17271
17272 case BUTTONHELD:
17273 {
17274 //Read-only
17275 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
17276 button_hold[button]=(value?true:false);
17277 }
17278 break;
17279
17280 case RAWKEY:
17281 { //Game->KeyPressed[], read-only
17282 //if ( !keypressed() ) break; //Don;t return values set by setting Hero->Input/Press
17283 //hmm...no, this won;t return properly for modifier keys.
17284 int32_t keyid = ri->d[rINDEX]/10000;
17285 //key = vbound(key,0,n);
17286 _key[keyid]=key[keyid]=key_current_frame[keyid]=(value?true:false); //It isn't possible to set keys true, because polling occurs before they are set?
17287 //but they *can* be set false; ??? -Z
17288 }
17289 break;
17290
17291 case KEYINPUT:
17292 {
17293 KeyInput[ri->d[rINDEX]/10000] = (value/10000)!=0;
17294 switch(ri->d[rINDEX]/10000)
17295 {
17296 case KEY_F6: onTryQuit(); break;
17297 case KEY_F3: Paused = !Paused; break;
17298 case KEY_F4: Paused = true; Advance = true; break;
17299 }
17300 break;
17301 }
17302 case KEYPRESS:
17303 {
17304 KeyPress[ri->d[rINDEX]/10000] = (value/10000)!=0;
17305 break;
17306 }
17307
17308 case SIMULATEKEYPRESS:
17309 { //Game->KeyPressed[], read-only
17310 //if ( !keypressed() ) break; //Don;t return values set by setting Hero->Input/Press
17311 //hmm...no, this won;t return properly for modifier keys.
17312 int32_t keyid = ri->d[rINDEX]/10000;
17313 //key = vbound(key,0,n);
17314 if (value/10000) simulate_keypress(keyid << 8);
17315 }
17316 break;
17317
17318 case KEYMODIFIERS:
17319 {
17320 key_shifts = ( value/10000 );
17321 break;
17322 }
17323
17324 case KEYBINDINGS:
17325 {
17326 int32_t keyid = ri->d[rINDEX]/10000;
17327 switch(keyid)
17328 {
17329 case 0: DUkey = ( value/10000 ); break;
17330 case 1: DDkey = ( value/10000 ); break;
17331 case 2: DLkey = ( value/10000 ); break;
17332 case 3: DRkey = ( value/10000 ); break;
17333 case 4: Akey = ( value/10000 ); break;
17334 case 5: Bkey = ( value/10000 ); break;
17335 case 6: Skey = ( value/10000 ); break;
17336 case 7: Lkey = ( value/10000 ); break;
17337 case 8: Rkey = ( value/10000 ); break;
17338 case 9: Pkey = ( value/10000 ); /*map*/ break;
17339 case 10: Exkey1 = ( value/10000 ); break;
17340 case 11: Exkey2 = ( value/10000 ); break;
17341 case 12: Exkey3 = ( value/10000 ); break;
17342 case 13: Exkey4 = ( value/10000 ); break;
17343
17344 default: { Z_scripterrlog("Invalid index [%d] passed to Input->KeyBindings[]\n", keyid); break; }
17345 }
17346 break;
17347 }
17348
17349 case DISABLEKEY:
17350 {
17351 //Input->DisableKey(int32_t key, bool disable)
17352 int32_t keyid = ri->d[rINDEX]/10000;
17353 if(!zc_disablekey(keyid, value))
17354 {
17355 //Z_scripterrlog("The key %d passed to Input->DisableKey[] is system-reserved, and cannot be disabled\n",keyid);
17356 }
17357 break;
17358 }
17359
17360 case DISABLEBUTTON:
17361 {
17362 //Input->DisableButton(int32_t cb, bool disable)
17363 int32_t cbid = ri->d[rINDEX]/10000;
17364 disable_control[cbid] = value?true:false;
17365 break;
17366 }
17367
17368 case MOUSEARR:
17369 {
17370 int32_t indx = (ri->d[rINDEX]/10000);
17371 switch (indx)
17372 {
17373 case 0: //MouseX
17374 {
17375 auto [x, y] = rti_game.local_to_world(value/10000, mouse_y);
17376 position_mouse(x, y);
17377 break;
17378 }
17379 case 1: //MouseY
17380 {
17381 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
17382 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset :(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17383 auto [x, y] = rti_game.local_to_world(mouse_x, value/10000 + tempoffset);
17384 position_mouse(x, y);
17385 break;
17386
17387 }
17388 case 2: //MouseZ
17389 {
17390 position_mouse_z(value/10000);
17391 break;
17392 }
17393 case 3: //Left Click
17394 {
17395 if ( value ) mouse_b |= 1;
17396 else mouse_b &= ~1;
17397 break;
17398 }
17399 case 4: //Right Click
17400 {
17401 if ( value ) mouse_b |= 2;
17402 else mouse_b &= ~2;
17403 break;
17404 }
17405 case 5: //Middle Click
17406 {
17407 if ( value ) mouse_b |= 4;
17408 else mouse_b &= ~4;
17409 break;
17410 }
17411 default:
17412 {
17413 Z_scripterrlog("Invalid index passed to Input->Mouse[]: %d\n", indx);
17414 }
17415 }
17416
17417 }
17418 break;
17419
17420
17421 ///----------------------------------------------------------------------------------------------------//
17422 //Item Variables
17423
17424 case ITEMFAMILY:
17425 if(0!=(s=checkItem(ri->itemref)))
17426 {
17427 (((item *)s)->family)=value/10000;
17428 }
17429
17430 break;
17431
17432 case ITEMLEVEL:
17433 if(0!=(s=checkItem(ri->itemref)))
17434 {
17435 (((item *)s)->lvl)=value/10000;
17436 }
17437
17438 break;
17439
17440 case SPRITEMAXITEM:
17441 {
17442 //No bounds check, as this is a universal function and works from NULL pointers!
17443 items.setMax(vbound((value/10000),1,MAX_ITEM_SPRITES));
17444 break;
17445 }
17446
17447 case ITEMX:
17448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21848 times.
21848 if(0!=(s=checkItem(ri->itemref)))
17449 {
17450
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 21678 times.
21848 (s->x)=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17451
17452 // Move the Fairy enemy as well.
17453
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 21838 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
21848 if(itemsbuf[((item*)(s))->id].family==itype_fairy && itemsbuf[((item*)(s))->id].misc3)
17454 movefairynew2(((item*)(s))->x,((item*)(s))->y,*((item*)(s)));
17455 21848 }
17456
17457 21848 break;
17458
17459 case ITEMSPRITESCRIPT:
17460 31 FFScript::deallocateAllScriptOwned(ScriptType::ItemSprite, ri->itemref);
17461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(0!=(s=checkItem(ri->itemref)))
17462 {
17463 31 (s->script)=(value/10000);
17464 31 }
17465 31 break;
17466
17467 case ITEMSCALE:
17468 if ( get_qr(qr_OLDSPRITEDRAWS) )
17469 {
17470 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
17471 "item->Scale");
17472 break;
17473 }
17474 if(0!=(s=checkItem(ri->itemref)))
17475 {
17476 (s->scale)=(zfix)(value/100.0);
17477 }
17478
17479 break;
17480
17481 case ITEMY:
17482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41791 times.
41791 if(0!=(s=checkItem(ri->itemref)))
17483 {
17484
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 40649 times.
41791 (s->y)=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17485
17486 // Move the Fairy enemy as well.
17487
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 41781 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
41791 if(itemsbuf[((item*)(s))->id].family==itype_fairy && itemsbuf[((item*)(s))->id].misc3)
17488 movefairynew2(((item*)(s))->x,((item*)(s))->y,*((item*)(s)));
17489 41791 }
17490
17491 41791 break;
17492
17493 case ITEMZ:
17494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(0!=(s=checkItem(ri->itemref)))
17495 {
17496 92 (s->z)=(zfix)(value/10000);
17497
17498
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(s->z < 0)
17499 s->z = 0;
17500 92 }
17501
17502 92 break;
17503
17504 case ITEMJUMP:
17505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49959 times.
49959 if(0!=(s=checkItem(ri->itemref)))
17506 {
17507 49959 (((item *)s)->fall)=zslongToFix(value)*-100;
17508 49959 }
17509
17510 49959 break;
17511
17512 case ITEMFAKEJUMP:
17513 if(0!=(s=checkItem(ri->itemref)))
17514 {
17515 (((item *)s)->fakefall)=zslongToFix(value)*-100;
17516 }
17517
17518 break;
17519
17520 case ITEMDRAWTYPE:
17521 if(0!=(s=checkItem(ri->itemref)))
17522 {
17523 (((item *)s)->drawstyle)=value/10000;
17524 }
17525
17526 break;
17527
17528 case ITEMSPRITEINITD:
17529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(0!=(s=checkItem(ri->itemref)))
17530 {
17531 37 int32_t a = vbound(ri->d[rINDEX]/10000,0,7);
17532 37 (((item *)s)->initD[a])=value;
17533 37 }
17534
17535 37 break;
17536
17537 case ITEMGRAVITY:
17538 if(0!=(s=checkItem(ri->itemref)))
17539 {
17540 if(value)
17541 ((item *)s)->moveflags |= FLAG_OBEYS_GRAV;
17542 else
17543 ((item *)s)->moveflags &= ~FLAG_OBEYS_GRAV;
17544 }
17545
17546 break;
17547
17548 case ITEMID:
17549 if(0!=(s=checkItem(ri->itemref)))
17550 {
17551 (((item *)s)->id)=value/10000;
17552 flushItemCache();
17553 }
17554
17555 break;
17556
17557 case ITEMTILE:
17558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(0!=(s=checkItem(ri->itemref)))
17559 {
17560 109 (((item *)s)->tile)=vbound(value/10000,0,NEWMAXTILES-1);
17561 109 }
17562
17563 109 break;
17564
17565 case ITEMSCRIPTTILE:
17566 if(0!=(s=checkItem(ri->itemref)))
17567 {
17568 (((item *)s)->scripttile)=vbound(value/10000,-1,NEWMAXTILES-1);
17569 }
17570 break;
17571
17572 case ITEMSCRIPTFLIP:
17573 if(0!=(s=checkItem(ri->itemref)))
17574 {
17575 (((item *)s)->scriptflip)=vbound((value/10000),-1,127);
17576 }
17577 break;
17578
17579 case ITEMPSTRING:
17580 if(0!=(s=checkItem(ri->itemref)))
17581 {
17582 (((item *)s)->pstring)=vbound(value/10000,0,(msg_count-1));
17583 }
17584
17585 break;
17586
17587 case ITEMPSTRINGFLAGS:
17588 if(0!=(s=checkItem(ri->itemref)))
17589 {
17590 (((item *)s)->pickup_string_flags)=vbound(value/10000, 0, 214748);
17591 }
17592
17593 break;
17594
17595 case ITEMOVERRIDEFLAGS:
17596 break;
17597
17598 case ITEMOTILE:
17599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(0!=(s=checkItem(ri->itemref)))
17600 {
17601 40 (((item *)s)->o_tile)=vbound(value/10000,0,NEWMAXTILES-1);
17602 40 }
17603
17604 40 break;
17605
17606 case ITEMCSET:
17607 if(0!=(s=checkItem(ri->itemref)))
17608 {
17609 (((item *)s)->o_cset) = (((item *)s)->o_cset & ~15) | ((value/10000)&15);
17610 (((item *)s)->cs) = (((item *)s)->o_cset & 15);
17611 }
17612
17613 break;
17614
17615 case ITEMFLASHCSET:
17616 if(0!=(s=checkItem(ri->itemref)))
17617 {
17618 (((item *)s)->o_cset) = ((value/10000)<<4) | (((item *)s)->o_cset & 15);
17619 }
17620
17621 break;
17622
17623 case ITEMFRAMES:
17624 if(0!=(s=checkItem(ri->itemref)))
17625 {
17626 (((item *)s)->frames)=value/10000;
17627 }
17628
17629 break;
17630
17631 case ITEMFRAME:
17632 if(0!=(s=checkItem(ri->itemref)))
17633 {
17634 (((item *)s)->aframe)=value/10000;
17635 }
17636
17637 break;
17638
17639 case ITEMASPEED:
17640 if(0!=(s=checkItem(ri->itemref)))
17641 {
17642 (((item *)s)->o_speed)=value/10000;
17643 }
17644
17645 break;
17646
17647 case ITEMACLK:
17648 if(0!=(s=checkItem(ri->itemref)))
17649 {
17650 (((item *)s)->aclk)=value/10000;
17651 }
17652
17653 break;
17654
17655 case ITEMDELAY:
17656 if(0!=(s=checkItem(ri->itemref)))
17657 {
17658 (((item *)s)->o_delay)=value/10000;
17659 }
17660
17661 break;
17662
17663 case ITEMFLIP:
17664 if(0!=(s=checkItem(ri->itemref)))
17665 {
17666 (((item *)s)->flip)=value/10000;
17667 }
17668
17669 break;
17670
17671 case ITEMFLASH:
17672 if(0!=(s=checkItem(ri->itemref)))
17673 {
17674 (((item *)s)->flash)= (value/10000)?1:0;
17675 }
17676
17677 break;
17678
17679 case ITEMEXTEND:
17680 if(0!=(s=checkItem(ri->itemref)))
17681 {
17682 (((item *)s)->extend)=value/10000;
17683 }
17684
17685 break;
17686
17687 case ITEMHXOFS:
17688 if(0!=(s=checkItem(ri->itemref)))
17689 {
17690 ((item*)(s))->hxofs=value/10000;
17691 }
17692
17693 break;
17694
17695 case ITEMROTATION:
17696 if ( get_qr(qr_OLDSPRITEDRAWS) )
17697 {
17698 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
17699 "item->Rotation");
17700 break;
17701 }
17702 if(0!=(s=checkItem(ri->itemref)))
17703 {
17704 ((item*)(s))->rotation=value/10000;
17705 }
17706
17707 break;
17708
17709 case ITEMHYOFS:
17710 if(0!=(s=checkItem(ri->itemref)))
17711 {
17712 ((item*)(s))->hyofs=value/10000;
17713 }
17714
17715 break;
17716
17717 case ITEMXOFS:
17718 if(0!=(s=checkItem(ri->itemref)))
17719 {
17720 ((item*)(s))->xofs=(zfix)(value/10000);
17721 }
17722
17723 break;
17724
17725 case ITEMYOFS:
17726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(0!=(s=checkItem(ri->itemref)))
17727 {
17728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 ((item*)(s))->yofs=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17729 6 }
17730
17731 6 break;
17732
17733 case ITEMSHADOWXOFS:
17734 if(0!=(s=checkItem(ri->itemref)))
17735 {
17736 ((item*)(s))->shadowxofs=(zfix)(value/10000);
17737 }
17738
17739 break;
17740
17741 case ITEMSHADOWYOFS:
17742 if(0!=(s=checkItem(ri->itemref)))
17743 {
17744 ((item*)(s))->shadowyofs=(zfix)(value/10000);
17745 }
17746
17747 break;
17748
17749 case ITEMZOFS:
17750 if(0!=(s=checkItem(ri->itemref)))
17751 {
17752 ((item*)(s))->zofs=(zfix)(value/10000);
17753 }
17754
17755 break;
17756
17757 case ITEMHXSZ:
17758 if(0!=(s=checkItem(ri->itemref)))
17759 {
17760 ((item*)(s))->hit_width=value/10000;
17761 }
17762
17763 break;
17764
17765 case ITEMHYSZ:
17766 if(0!=(s=checkItem(ri->itemref)))
17767 {
17768 ((item*)(s))->hit_height=value/10000;
17769 }
17770
17771 break;
17772
17773 case ITEMHZSZ:
17774 if(0!=(s=checkItem(ri->itemref)))
17775 {
17776 ((item*)(s))->hzsz=value/10000;
17777 }
17778
17779 break;
17780
17781 case ITEMTXSZ:
17782 if(0!=(s=checkItem(ri->itemref)))
17783 {
17784 ((item*)(s))->txsz=vbound((value/10000),1,20);
17785 }
17786
17787 break;
17788
17789 case ITEMTYSZ:
17790 if(0!=(s=checkItem(ri->itemref)))
17791 {
17792 ((item*)(s))->tysz=vbound((value/10000),1,20);
17793 }
17794
17795 break;
17796
17797 case ITEMPICKUP:
17798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1181 times.
1181 if(0!=(s=checkItem(ri->itemref)))
17799 {
17800 1181 int32_t newpickup = value/10000;
17801 // Values that the questmaker should not use, ever
17802 //Allowing it, for now, until something breaks. -Z 21-Jan-2020
17803 //newpickup &= ~(ipBIGRANGE | ipCHECK | ipMONEY | ipBIGTRI | ipNODRAW | ipFADE);
17804 //
17805
4/4
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 461 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 264 times.
1181 if (( FFCore.GetQuestVersion() == 0x250 && FFCore.GetQuestBuild() < 33 ) //this ishowit looks in 2.53.1, Beta 25
17806 1181 || ( FFCore.GetQuestVersion() < 0x250 ))
17807 {
17808 917 newpickup &= ~(ipBIGRANGE | ipCHECK | ipMONEY | ipBIGTRI | ipNODRAW | ipFADE);
17809 917 }
17810
17811 // If making an item timeout, set its timer
17812
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 70 times.
787 if(newpickup & ipFADE)
17813 {
17814 70 (((item*)(s))->clk2) = 512;
17815 70 }
17816 //else if(newpickup & ~ipFADE)
17817 //{
17818 // (((item*)(s))->clk2) = 0;
17819 //}
17820
17821 // If making it a carried item,
17822 // alter hasitem and set an itemguy.
17823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if((((item*)(s))->pickup & ipENEMY) < (newpickup & ipENEMY))
17824 {
17825 hasitem |= 2;
17826 bool hasitemguy = false;
17827
17828 for(int32_t i=0; i<guys.Count(); i++)
17829 {
17830 if(((enemy*)guys.spr(i))->itemguy)
17831 {
17832 hasitemguy = true;
17833 }
17834 }
17835
17836 if(!hasitemguy && guys.Count()>0)
17837 {
17838 ((enemy*)guys.spr(guys.Count()-1))->itemguy = true;
17839 }
17840 }
17841 // If unmaking it a carried item,
17842 // alter hasitem if there are no more carried items.
17843
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 else if((((item*)(s))->pickup & ipENEMY) > (newpickup & ipENEMY))
17844 {
17845 // Move it back onscreen!
17846 if(get_qr(qr_HIDECARRIEDITEMS))
17847 {
17848 for(int32_t i=0; i<guys.Count(); i++)
17849 {
17850 if(((enemy*)guys.spr(i))->itemguy)
17851 {
17852 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
17853 {
17854 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
17855 {
17856 ((item*)(s))->x = ((enemy*)guys.spr(i))->x+((enemy*)guys.spr(i))->hxofs+(((enemy*)guys.spr(i))->hit_width/2)-8;
17857 ((item*)(s))->y = ((enemy*)guys.spr(i))->y+((enemy*)guys.spr(i))->hyofs+(((enemy*)guys.spr(i))->hit_height/2)-10;
17858 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
17859 }
17860 else
17861 {
17862 if(((enemy*)guys.spr(i))->extend >= 3)
17863 {
17864 ((item*)(s))->x = ((enemy*)guys.spr(i))->x+(((enemy*)guys.spr(i))->txsz-1)*8;
17865 ((item*)(s))->y = ((enemy*)guys.spr(i))->y-2+(((enemy*)guys.spr(i))->tysz-1)*8;
17866 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
17867 }
17868 else
17869 {
17870 ((item*)(s))->x = ((enemy*)guys.spr(i))->x;
17871 ((item*)(s))->y = ((enemy*)guys.spr(i))->y - 2;
17872 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
17873 }
17874 }
17875 }
17876 else
17877 {
17878 ((item*)(s))->x = ((enemy*)guys.spr(i))->x;
17879 ((item*)(s))->y = ((enemy*)guys.spr(i))->y - 2;
17880 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
17881 }
17882 break;
17883 }
17884 }
17885 }
17886
17887 if(more_carried_items()<=1) // 1 includes this own item.
17888 {
17889 hasitem &= ~2;
17890 }
17891 }
17892
17893 787 ((item*)(s))->pickup=value/10000;
17894 787 }
17895
17896 787 break;
17897
17898 case ITEMMISCD:
17899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3013 times.
3013 if(0!=(s=checkItem(ri->itemref)))
17900 {
17901 3013 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
17902 3013 (((item*)(s))->miscellaneous[a])=value;
17903 3013 }
17904
17905 3013 break;
17906 case ITEMFALLCLK:
17907 if(0!=(s=checkItem(ri->itemref)))
17908 {
17909 if(((item*)(s))->fallclk != 0 && value == 0)
17910 {
17911 ((item*)(s))->cs = ((item*)(s))->old_cset;
17912 ((item*)(s))->tile = ((item*)(s))->o_tile;
17913 }
17914 else if(((item*)(s))->fallclk == 0 && value != 0) ((item*)(s))->old_cset = ((item*)(s))->cs;
17915 ((item*)(s))->fallclk = vbound(value/10000,0,70);
17916 }
17917 break;
17918 case ITEMFALLCMB:
17919 if(0!=(s=checkItem(ri->itemref)))
17920 {
17921 ((item*)(s))->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
17922 }
17923 break;
17924 case ITEMDROWNCLK:
17925 if(0!=(s=checkItem(ri->itemref)))
17926 {
17927 if(((item*)(s))->drownclk != 0 && value == 0)
17928 {
17929 ((item*)(s))->cs = ((item*)(s))->old_cset;
17930 ((item*)(s))->tile = ((item*)(s))->o_tile;
17931 }
17932 else if(((item*)(s))->drownclk == 0 && value != 0) ((item*)(s))->old_cset = ((item*)(s))->cs;
17933 ((item*)(s))->drownclk = vbound(value/10000,0,70);
17934 }
17935 break;
17936 case ITEMDROWNCMB:
17937 if(0!=(s=checkItem(ri->itemref)))
17938 {
17939 ((item*)(s))->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
17940 }
17941 break;
17942 case ITEMFAKEZ:
17943 if(0!=(s=checkItem(ri->itemref)))
17944 {
17945 (s->fakez)=(zfix)(value/10000);
17946
17947 if(s->fakez < 0)
17948 s->fakez = 0;
17949 }
17950
17951 break;
17952
17953 case ITEMMOVEFLAGS:
17954 {
17955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(0!=(s=checkItem(ri->itemref)))
17956 {
17957 68 int32_t indx = ri->d[rINDEX]/10000;
17958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(BC::checkBounds(indx, 0, 10, "itemsprite->MoveFlags[]") == SH::_NoError)
17959 {
17960 //All bits, in order, of a single byte; just use bitwise
17961 68 int32_t bit = 1<<indx;
17962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(value)
17963 ((item*)(s))->moveflags |= bit;
17964 else
17965 68 ((item*)(s))->moveflags &= ~bit;
17966 68 }
17967 68 }
17968 68 break;
17969 }
17970
17971 case ITEMGLOWRAD:
17972 if(0!=(s=checkItem(ri->itemref)))
17973 {
17974 ((item*)(s))->glowRad = vbound(value/10000,0,255);
17975 }
17976 break;
17977
17978 case ITEMGLOWSHP:
17979 if(0!=(s=checkItem(ri->itemref)))
17980 {
17981 ((item*)(s))->glowShape = vbound(value/10000,0,255);
17982 }
17983 break;
17984
17985 case ITEMDIR:
17986 if(0!=(s=checkItem(ri->itemref)))
17987 {
17988 ((item*)(s))->dir=(value/10000);
17989 }
17990 break;
17991
17992 case ITEMENGINEANIMATE:
17993 if(0!=(s=checkItem(ri->itemref)))
17994 {
17995 ((item*)(s))->do_animation=(value ? 1 : 0);
17996 }
17997 break;
17998
17999 case ITEMSHADOWSPR:
18000 if(0!=(s=checkItem(ri->itemref)))
18001 {
18002 ((item*)(s))->spr_shadow=vbound(value/10000,0,255);
18003 }
18004 break;
18005 case ITEMDROPPEDBY:
18006 if(0!=(s=checkItem(ri->itemref)))
18007 {
18008 ((item*)(s))->from_dropset=vbound(value/10000,-1,255);
18009 }
18010 break;
18011 case ITMSWHOOKED:
18012 break; //read-only
18013 case ITEMFORCEGRAB:
18014 if(0!=(s=checkItem(ri->itemref)))
18015 {
18016 ((item*)(s))->set_forcegrab(value!=0);
18017 }
18018 break;
18019
18020 ///----------------------------------------------------------------------------------------------------//
18021 //Itemdata Variables
18022 //not mine, but let;s guard some of them all the same -Z
18023 //item class
18024 case IDATAFAMILY:
18025 if(unsigned(ri->idata) >= MAXITEMS)
18026 {
18027 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18028 break;
18029 }
18030 (itemsbuf[ri->idata].family)=vbound(value/10000,0, 254);
18031 flushItemCache();
18032 break;
18033
18034 case IDATAUSEWPN:
18035 if(unsigned(ri->idata) >= MAXITEMS)
18036 {
18037 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18038 break;
18039 }
18040 (itemsbuf[ri->idata].useweapon)=vbound(value/10000, 0, 255);
18041 break;
18042 case IDATAUSEDEF:
18043 if(unsigned(ri->idata) >= MAXITEMS)
18044 {
18045 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18046 break;
18047 }
18048 (itemsbuf[ri->idata].usedefence)=vbound(value/10000, 0, 255);
18049 break;
18050 case IDATAWRANGE:
18051 if(unsigned(ri->idata) >= MAXITEMS)
18052 {
18053 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18054 break;
18055 }
18056 (itemsbuf[ri->idata].weaprange)=vbound(value/10000, 0, 255);
18057 break;
18058 case IDATAMAGICTIMER:
18059 if(unsigned(ri->idata) >= MAXITEMS)
18060 {
18061 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18062 break;
18063 }
18064 (itemsbuf[ri->idata].magiccosttimer[0])=vbound(value/10000, 0, 214747);
18065 break;
18066 case IDATAMAGICTIMER2:
18067 if(unsigned(ri->idata) >= MAXITEMS)
18068 {
18069 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18070 break;
18071 }
18072 (itemsbuf[ri->idata].magiccosttimer[1])=vbound(value/10000, 0, 214747);
18073 break;
18074 case IDATADURATION:
18075 if(unsigned(ri->idata) >= MAXITEMS)
18076 {
18077 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18078 break;
18079 }
18080 (itemsbuf[ri->idata].weapduration)=vbound(value/10000, 0, 255);
18081 break;
18082
18083 case IDATADUPLICATES:
18084 if(unsigned(ri->idata) >= MAXITEMS)
18085 {
18086 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18087 break;
18088 }
18089 (itemsbuf[ri->idata].duplicates)=vbound(value/10000, 0, 255);
18090 break;
18091 case IDATADRAWLAYER:
18092 if(unsigned(ri->idata) >= MAXITEMS)
18093 {
18094 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18095 break;
18096 }
18097 (itemsbuf[ri->idata].drawlayer)=vbound(value/10000, 0, 7);
18098 break;
18099 case IDATACOLLECTFLAGS:
18100 if(unsigned(ri->idata) >= MAXITEMS)
18101 {
18102 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18103 break;
18104 }
18105 //int32_t a = ri->d[rINDEX] / 10000;
18106 (itemsbuf[ri->idata].collectflags)=vbound(value/10000, 0, 214747);
18107 break;
18108 case IDATAWEAPONSCRIPT:
18109 if(unsigned(ri->idata) >= MAXITEMS)
18110 {
18111 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18112 break;
18113 }
18114 (itemsbuf[ri->idata].weaponscript)=vbound(value/10000, 0, 255);
18115 break;
18116 case IDATAMISCD:
18117 {
18118 if(unsigned(ri->idata) >= MAXITEMS)
18119 {
18120 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18121 break;
18122 }
18123 int32_t a = vbound((ri->d[rINDEX] / 10000),0,31);
18124 (itemsbuf[ri->idata].wpn_misc_d[a])=(value/10000);
18125 }
18126 break;
18127 case IDATAWPNINITD:
18128 {
18129 if(unsigned(ri->idata) >= MAXITEMS)
18130 {
18131 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18132 break;
18133 }
18134 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
18135 (itemsbuf[ri->idata].weap_initiald[a])=(value);
18136 }
18137 break;
18138 case IDATAWEAPHXOFS:
18139 if(unsigned(ri->idata) >= MAXITEMS)
18140 {
18141 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18142 break;
18143 }
18144 (itemsbuf[ri->idata].weap_hxofs)=(value/10000);
18145 break;
18146 case IDATAWEAPHYOFS:
18147 if(unsigned(ri->idata) >= MAXITEMS)
18148 {
18149 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18150 break;
18151 }
18152 (itemsbuf[ri->idata].weap_hyofs)=(value/10000);
18153 break;
18154 case IDATAWEAPHXSZ:
18155 if(unsigned(ri->idata) >= MAXITEMS)
18156 {
18157 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18158 break;
18159 }
18160 (itemsbuf[ri->idata].weap_hxsz)=(value/10000);
18161 break;
18162 case IDATAWEAPHYSZ:
18163 if(unsigned(ri->idata) >= MAXITEMS)
18164 {
18165 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18166 break;
18167 }
18168 (itemsbuf[ri->idata].weap_hysz)=(value/10000);
18169 break;
18170 case IDATAWEAPHZSZ:
18171 if(unsigned(ri->idata) >= MAXITEMS)
18172 {
18173 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18174 break;
18175 }
18176 (itemsbuf[ri->idata].weap_hzsz)=(value/10000);
18177 break;
18178 case IDATAWEAPXOFS:
18179 if(unsigned(ri->idata) >= MAXITEMS)
18180 {
18181 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18182 break;
18183 }
18184 (itemsbuf[ri->idata].weap_xofs)=(value/10000);
18185 break;
18186 case IDATAWEAPYOFS:
18187 if(unsigned(ri->idata) >= MAXITEMS)
18188 {
18189 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18190 break;
18191 }
18192 (itemsbuf[ri->idata].weap_yofs)=(value/10000);
18193 break;
18194
18195
18196 case IDATAHXOFS:
18197 if(unsigned(ri->idata) >= MAXITEMS)
18198 {
18199 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18200 break;
18201 }
18202 (itemsbuf[ri->idata].hxofs)=(value/10000);
18203 break;
18204 case IDATAHYOFS:
18205 if(unsigned(ri->idata) >= MAXITEMS)
18206 {
18207 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18208 break;
18209 }
18210 (itemsbuf[ri->idata].hyofs)=(value/10000);
18211 break;
18212 case IDATAHXSZ:
18213 if(unsigned(ri->idata) >= MAXITEMS)
18214 {
18215 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18216 break;
18217 }
18218 (itemsbuf[ri->idata].hxsz)=(value/10000);
18219 break;
18220 case IDATAHYSZ:
18221 if(unsigned(ri->idata) >= MAXITEMS)
18222 {
18223 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18224 break;
18225 }
18226 (itemsbuf[ri->idata].hysz)=(value/10000);
18227 break;
18228 case IDATAHZSZ:
18229 if(unsigned(ri->idata) >= MAXITEMS)
18230 {
18231 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18232 break;
18233 }
18234 (itemsbuf[ri->idata].hzsz)=(value/10000);
18235 break;
18236 case IDATADXOFS:
18237 if(unsigned(ri->idata) >= MAXITEMS)
18238 {
18239 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18240 break;
18241 }
18242 (itemsbuf[ri->idata].xofs)=(value/10000);
18243 break;
18244 case IDATADYOFS:
18245 if(unsigned(ri->idata) >= MAXITEMS)
18246 {
18247 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18248 break;
18249 }
18250 (itemsbuf[ri->idata].yofs)=(value/10000);
18251 break;
18252 case IDATATILEW:
18253 if(unsigned(ri->idata) >= MAXITEMS)
18254 {
18255 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18256 break;
18257 }
18258 (itemsbuf[ri->idata].tilew)=(value/10000);
18259 break;
18260 case IDATATILEH:
18261 if(unsigned(ri->idata) >= MAXITEMS)
18262 {
18263 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18264 break;
18265 }
18266 (itemsbuf[ri->idata].tileh)=(value/10000);
18267 break;
18268 case IDATAPICKUP:
18269 if(unsigned(ri->idata) >= MAXITEMS)
18270 {
18271 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18272 break;
18273 }
18274 (itemsbuf[ri->idata].pickup)=(value/10000);
18275 break;
18276 case IDATAOVERRIDEFL:
18277 if(unsigned(ri->idata) >= MAXITEMS)
18278 {
18279 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18280 break;
18281 }
18282 (itemsbuf[ri->idata].overrideFLAGS)=(value/10000);
18283 break;
18284
18285 case IDATATILEWWEAP:
18286 if(unsigned(ri->idata) >= MAXITEMS)
18287 {
18288 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18289 break;
18290 }
18291 (itemsbuf[ri->idata].weap_tilew)=(value/10000);
18292 break;
18293 case IDATATILEHWEAP:
18294 if(unsigned(ri->idata) >= MAXITEMS)
18295 {
18296 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18297 break;
18298 }
18299 (itemsbuf[ri->idata].weap_tileh)=(value/10000);
18300 break;
18301 case IDATAOVERRIDEFLWEAP:
18302 if(unsigned(ri->idata) >= MAXITEMS)
18303 {
18304 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18305 break;
18306 }
18307 (itemsbuf[ri->idata].weapoverrideFLAGS)=(value/10000);
18308 break;
18309
18310 case IDATAUSEMVT:
18311 {
18312 if(unsigned(ri->idata) >= MAXITEMS)
18313 {
18314 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18315 break;
18316 }
18317 int32_t a = vbound((ri->d[rINDEX] / 10000),0,(ITEM_MOVEMENT_PATTERNS-1));
18318 (itemsbuf[ri->idata].weap_pattern[a])=vbound(value/10000, 0, 255);
18319 break;
18320 }
18321
18322 case IDATALEVEL:
18323 if(unsigned(ri->idata) >= MAXITEMS)
18324 {
18325 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18326 break;
18327 }
18328 (itemsbuf[ri->idata].fam_type)=vbound(value/10000, 0, 512);
18329 flushItemCache();
18330 break;
18331 case IDATAKEEP:
18332 item_flag(ITEM_GAMEDATA, value);
18333 break;
18334 case IDATAAMOUNT:
18335 {
18336 if(unsigned(ri->idata) >= MAXITEMS)
18337 {
18338 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18339 break;
18340 }
18341 int32_t v = vbound(value/10000, -9999, 16383);
18342 itemsbuf[ri->idata].amount &= 0x8000;
18343 itemsbuf[ri->idata].amount |= (abs(v)&0x3FFF)|(v<0?0x4000:0);
18344 break;
18345 }
18346 case IDATAGRADUAL:
18347 {
18348 if(unsigned(ri->idata) >= MAXITEMS)
18349 {
18350 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18351 break;
18352 }
18353 SETFLAG(itemsbuf[ri->idata].amount, 0x8000, value!=0);
18354 break;
18355 }
18356 case IDATACONSTSCRIPT:
18357 item_flag(ITEM_PASSIVESCRIPT, value);
18358 break;
18359 case IDATASSWIMDISABLED:
18360 item_flag(ITEM_SIDESWIM_DISABLED, value);
18361 break;
18362 case IDATABUNNYABLE:
18363 item_flag(ITEM_BUNNY_ENABLED, value);
18364 break;
18365 case IDATAJINXIMMUNE:
18366 item_flag(ITEM_JINX_IMMUNE, value);
18367 break;
18368 case IDATAJINXSWAP:
18369 item_flag(ITEM_FLIP_JINX, value);
18370 break;
18371 case IDATASETMAX:
18372 if(unsigned(ri->idata) >= MAXITEMS)
18373 {
18374 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18375 break;
18376 }
18377 (itemsbuf[ri->idata].setmax)=value/10000;
18378 break;
18379
18380 case IDATAMAX:
18381 if(unsigned(ri->idata) >= MAXITEMS)
18382 {
18383 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18384 break;
18385 }
18386 (itemsbuf[ri->idata].max)=value/10000;
18387 break;
18388
18389 case IDATAPOWER:
18390 if(unsigned(ri->idata) >= MAXITEMS)
18391 {
18392 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18393 break;
18394 }
18395 (itemsbuf[ri->idata].power)=value/10000;
18396 break;
18397
18398 case IDATACOUNTER:
18399 if(unsigned(ri->idata) >= MAXITEMS)
18400 {
18401 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18402 break;
18403 }
18404 (itemsbuf[ri->idata].count)=vbound(value/10000,0,31);
18405 break;
18406
18407 case IDATAPSOUND:
18408 if(unsigned(ri->idata) >= MAXITEMS)
18409 {
18410 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18411 break;
18412 }
18413 (itemsbuf[ri->idata].playsound)=vbound(value/10000, 0, 255);
18414 break;
18415
18416 case IDATAUSESOUND:
18417 if(unsigned(ri->idata) >= MAXITEMS)
18418 {
18419 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18420 break;
18421 }
18422 (itemsbuf[ri->idata].usesound)=vbound(value/10000, 0, 255);
18423 break;
18424
18425 case IDATAUSESOUND2:
18426 if(unsigned(ri->idata) >= MAXITEMS)
18427 {
18428 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18429 break;
18430 }
18431 (itemsbuf[ri->idata].usesound2)=vbound(value/10000, 0, 255);
18432 break;
18433
18434 //2.54
18435 //My additions begin here. -Z
18436 //Stack item to gain next level
18437 case IDATACOMBINE:
18438 item_flag(ITEM_COMBINE, value);
18439 break;
18440 //using a level of an item downgrades to a lower one
18441 case IDATADOWNGRADE:
18442 item_flag(ITEM_DOWNGRADE, value);
18443 break;
18444 //Only validate the cost, don't charge it
18445 case IDATAVALIDATE:
18446 item_flag(ITEM_VALIDATEONLY, value);
18447 break;
18448 case IDATAVALIDATE2:
18449 item_flag(ITEM_VALIDATEONLY2, value);
18450 break;
18451
18452 //Flags[5]
18453 case IDATAFLAGS:
18454 {
18455 if(unsigned(ri->idata) >= MAXITEMS)
18456 {
18457 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18458 break;
18459 }
18460 int32_t index = ri->d[rINDEX]/10000;
18461 switch(index)
18462 {
18463 case 0:
18464 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG1, value);
18465 break;
18466 case 1:
18467 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG2, value);
18468 break;
18469 case 2:
18470 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG3, value);
18471 break;
18472 case 3:
18473 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG4, value);
18474 break;
18475 case 4:
18476 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG5, value);
18477 break;
18478 case 5:
18479 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG6, value);
18480 break;
18481 case 6:
18482 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG7, value);
18483 break;
18484 case 7:
18485 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG8, value);
18486 break;
18487 case 8:
18488 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG9, value);
18489 cache_tile_mod_clear();
18490 break;
18491 case 9:
18492 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG10, value);
18493 break;
18494 case 10:
18495 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG11, value);
18496 break;
18497 case 11:
18498 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG12, value);
18499 break;
18500 case 12:
18501 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG13, value);
18502 break;
18503 case 13:
18504 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG14, value);
18505 break;
18506 case 14:
18507 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG15, value);
18508 break;
18509 case 15:
18510 SETFLAG(itemsbuf[ri->idata].flags, ITEM_PASSIVESCRIPT, value);
18511 break;
18512 }
18513
18514 break;
18515 }
18516 //Keep Old in editor
18517 case IDATAKEEPOLD:
18518 item_flag(ITEM_KEEPOLD, value);
18519 break;
18520 //Ruppes for magic
18521 case IDATARUPEECOST:
18522 item_flag(ITEM_RUPEE_MAGIC, value);
18523 break;
18524 //can be eaten
18525 case IDATAEDIBLE:
18526 item_flag(ITEM_EDIBLE, value);
18527 break;
18528 //Unused at this time
18529 case IDATAFLAGUNUSED:
18530 item_flag(ITEM_UNUSED, value);
18531 break;
18532 //gain lower level items
18533 case IDATAGAINLOWER:
18534 item_flag(ITEM_GAINOLD, value);
18535 break;
18536 //Set the action script
18537 case IDATASCRIPT:
18538 if(unsigned(ri->idata) >= MAXITEMS)
18539 {
18540 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18541 break;
18542 }
18543 FFScript::deallocateAllScriptOwned(ScriptType::Item, ri->idata);
18544 itemsbuf[ri->idata].script=vbound(value/10000,0,255);
18545 break;
18546 case IDATASPRSCRIPT:
18547 if(unsigned(ri->idata) >= MAXITEMS)
18548 {
18549 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18550 break;
18551 }
18552 itemsbuf[ri->idata].sprite_script=vbound(value/10000,0,255);
18553 break;
18554
18555 /*
18556 case ITEMMISCD:
18557 if(0!=(s=checkItem(ri->itemref)))
18558 {
18559 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
18560 (((item*)(s))->miscellaneous[a])=value;
18561 }
18562
18563 break;*/
18564 //Attributes[10]
18565 case IDATAATTRIB: {
18566 if(unsigned(ri->idata) >= MAXITEMS)
18567 {
18568 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18569 break;
18570 }
18571 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
18572 switch(index)
18573 {
18574 case 0:
18575 itemsbuf[ri->idata].misc1=value/10000;
18576 break;
18577 case 1:
18578 itemsbuf[ri->idata].misc2=value/10000; break;
18579 case 2:
18580 itemsbuf[ri->idata].misc3=value/10000; break;
18581 case 3:
18582 itemsbuf[ri->idata].misc4=value/10000; break;
18583 case 4:
18584 itemsbuf[ri->idata].misc5=value/10000; break;
18585 case 5:
18586 itemsbuf[ri->idata].misc6=value/10000; break;
18587 case 6:
18588 itemsbuf[ri->idata].misc7=value/10000; break;
18589 case 7:
18590 itemsbuf[ri->idata].misc8=value/10000; break;
18591 case 8:
18592 itemsbuf[ri->idata].misc9=value/10000; break;
18593 case 9:
18594 itemsbuf[ri->idata].misc10=value/10000; break;
18595
18596 default:
18597 break;
18598 }
18599
18600 break;
18601 }
18602 //SpriteSprites[10]
18603 case IDATASPRITE:
18604 {
18605 if(unsigned(ri->idata) >= MAXITEMS)
18606 {
18607 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18608 break;
18609 }
18610 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
18611 switch(index)
18612 {
18613 case 0:
18614 itemsbuf[ri->idata].wpn=vbound(value/10000, 0, 255);
18615 break;
18616 case 1:
18617 itemsbuf[ri->idata].wpn2=vbound(value/10000, 0, 255); break;
18618 case 2:
18619 itemsbuf[ri->idata].wpn3=vbound(value/10000, 0, 255); break;
18620 case 3:
18621 itemsbuf[ri->idata].wpn4=vbound(value/10000, 0, 255); break;
18622 case 4:
18623 itemsbuf[ri->idata].wpn5=vbound(value/10000, 0, 255); break;
18624 case 5:
18625 itemsbuf[ri->idata].wpn6=vbound(value/10000, 0, 255); break;
18626 case 6:
18627 itemsbuf[ri->idata].wpn7=vbound(value/10000, 0, 255); break;
18628 case 7:
18629 itemsbuf[ri->idata].wpn8=vbound(value/10000, 0, 255); break;
18630 case 8:
18631 itemsbuf[ri->idata].wpn9=vbound(value/10000, 0, 255); break;
18632 case 9:
18633 itemsbuf[ri->idata].wpn10=vbound(value/10000, 0, 255); break;
18634
18635 default:
18636 break;
18637 }
18638
18639 break;
18640 }
18641 //Hero tile modifier.
18642 case IDATALTM:
18643 {
18644 if(unsigned(ri->idata) >= MAXITEMS)
18645 {
18646 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18647 break;
18648 }
18649 auto new_value = value/10000;
18650 if (new_value != itemsbuf[ri->idata].ltm)
18651 cache_tile_mod_clear();
18652 itemsbuf[ri->idata].ltm = new_value;
18653 break;
18654 }
18655 //Pickup script
18656 case IDATAPSCRIPT:
18657 {
18658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2760 times.
2760 if(unsigned(ri->idata) >= MAXITEMS)
18659 {
18660 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18661 break;
18662 }
18663 //Need to get collect script ref, not standard idata ref!
18664
1/2
✓ Branch 0 taken 2760 times.
✗ Branch 1 not taken.
2760 const int32_t new_ref = ri->idata!=0 ? -(ri->idata) : COLLECT_SCRIPT_ITEM_ZERO;
18665 2760 FFScript::deallocateAllScriptOwned(ScriptType::Item,new_ref);
18666 2760 itemsbuf[ri->idata].collect_script=vbound(value/10000, 0, 255);
18667 2760 break;
18668 }
18669 //pickup string
18670 case IDATAPSTRING:
18671 if(unsigned(ri->idata) >= MAXITEMS)
18672 {
18673 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18674 break;
18675 }
18676 itemsbuf[ri->idata].pstring=vbound(value/10000, 1, 255);
18677 break;
18678 case IDATAPFLAGS:
18679 if(unsigned(ri->idata) >= MAXITEMS)
18680 {
18681 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18682 break;
18683 }
18684 itemsbuf[ri->idata].pickup_string_flags=vbound(value/10000, 0, 214748);
18685 break;
18686 //magic cost
18687 case IDATAMAGCOST:
18688 if(unsigned(ri->idata) >= MAXITEMS)
18689 {
18690 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18691 break;
18692 }
18693 itemsbuf[ri->idata].cost_amount[0]=vbound(value/10000,32767,-32768);
18694 break;
18695 case IDATACOST2:
18696 if(unsigned(ri->idata) >= MAXITEMS)
18697 {
18698 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18699 break;
18700 }
18701 itemsbuf[ri->idata].cost_amount[1]=vbound(value/10000,32767,-32768);
18702 break;
18703 //cost counter ref
18704 case IDATACOSTCOUNTER:
18705 if(unsigned(ri->idata) >= MAXITEMS)
18706 {
18707 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18708 break;
18709 }
18710 itemsbuf[ri->idata].cost_counter[0]=(vbound(value/10000,-1,32));
18711 break;
18712 case IDATACOSTCOUNTER2:
18713 if(unsigned(ri->idata) >= MAXITEMS)
18714 {
18715 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18716 break;
18717 }
18718 itemsbuf[ri->idata].cost_counter[1]=(vbound(value/10000,-1,32));
18719 break;
18720 //min hearts to pick up
18721 case IDATAMINHEARTS:
18722 if(unsigned(ri->idata) >= MAXITEMS)
18723 {
18724 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18725 break;
18726 }
18727 itemsbuf[ri->idata].pickup_hearts=vbound(value/10000, 0, 214748);
18728 break;
18729 //item tile
18730 case IDATATILE:
18731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(unsigned(ri->idata) >= MAXITEMS)
18732 {
18733 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18734 break;
18735 }
18736 70 itemsbuf[ri->idata].tile=vbound(value/10000, 0, 65519);
18737 70 break;
18738 //flash
18739 case IDATAMISC:
18740 if(unsigned(ri->idata) >= MAXITEMS)
18741 {
18742 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18743 break;
18744 }
18745 itemsbuf[ri->idata].misc_flags=value/10000;
18746 break;
18747 //cset
18748 case IDATACSET:
18749 if(unsigned(ri->idata) >= MAXITEMS)
18750 {
18751 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18752 break;
18753 }
18754 itemsbuf[ri->idata].csets=vbound(value/10000,0,13);
18755 break;
18756 /*
18757 case IDATAFRAME:
18758 itemsbuf[ri->idata].frame=value/10000;
18759 break;
18760 */
18761 //A.Frames
18762 case IDATAFRAMES:
18763 if(unsigned(ri->idata) >= MAXITEMS)
18764 {
18765 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18766 break;
18767 }
18768 (itemsbuf[ri->idata].frames)=vbound(value/10000, 0, 214748);
18769 break;
18770 //A.speed
18771 case IDATAASPEED:
18772 if(unsigned(ri->idata) >= MAXITEMS)
18773 {
18774 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18775 break;
18776 }
18777 itemsbuf[ri->idata].speed=vbound(value/10000, 0, 214748);
18778 break;
18779 //Anim delay
18780 case IDATADELAY:
18781 if(unsigned(ri->idata) >= MAXITEMS)
18782 {
18783 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18784 break;
18785 }
18786 itemsbuf[ri->idata].delay=vbound(value/10000, 0, 214748);
18787 break;
18788
18789 //not one of mine.
18790 case IDATAINITDD:
18791 {
18792 int32_t a = ri->d[rINDEX] / 10000;
18793 if(unsigned(ri->idata) >= MAXITEMS)
18794 {
18795 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18796 break;
18797 }
18798
18799 if(BC::checkBounds(a, 0, 7, "itemdata->InitD") == SH::_NoError)
18800 itemsbuf[ri->idata].initiald[a] = value;
18801 }
18802 break;
18803
18804 ///----------------------------------------------------------------------------------------------------//
18805 //LWeapon Variables
18806
18807 case LWPNSCALE:
18808 if ( get_qr(qr_OLDSPRITEDRAWS) )
18809 {
18810 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
18811 "lweapon->Scale");
18812 break;
18813 }
18814 if(0!=(s=checkLWpn(ri->lwpn,"Scale")))
18815 ((weapon*)s)->scale=(zfix)(value/100.0);
18816
18817 break;
18818
18819 case LWPNX:
18820
2/2
✓ Branch 0 taken 6717 times.
✓ Branch 1 taken 187023 times.
193740 if(0!=(s=checkLWpn(ri->lwpn,"X")))
18821
2/2
✓ Branch 0 taken 61572 times.
✓ Branch 1 taken 125451 times.
187023 ((weapon*)s)->x=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
18822 193740 break;
18823
18824 case SPRITEMAXLWPN:
18825 {
18826 //No bounds check, as this is a universal function and works from NULL pointers!
18827 Lwpns.setMax(vbound((value/10000),1,MAX_LWPN_SPRITES));
18828 break;
18829 }
18830
18831 case LWPNY:
18832
2/2
✓ Branch 0 taken 6717 times.
✓ Branch 1 taken 187016 times.
193733 if(0!=(s=checkLWpn(ri->lwpn,"Y")))
18833
2/2
✓ Branch 0 taken 61572 times.
✓ Branch 1 taken 125444 times.
187016 ((weapon*)s)->y=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
18834
18835 193733 break;
18836
18837 case LWPNZ:
18838 if(0!=(s=checkLWpn(ri->lwpn,"Z")))
18839 {
18840 ((weapon*)s)->z=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
18841 if(((weapon*)s)->z < 0) ((weapon*)s)->z = 0_zf;
18842 }
18843
18844 break;
18845
18846 case LWPNJUMP:
18847
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(0!=(s=checkLWpn(ri->lwpn,"Jump")))
18848 180 ((weapon*)s)->fall=zslongToFix(value)*-100;
18849
18850 180 break;
18851
18852 case LWPNFAKEJUMP:
18853 if(0!=(s=checkLWpn(ri->lwpn,"FakeJump")))
18854 ((weapon*)s)->fakefall=zslongToFix(value)*-100;
18855
18856 break;
18857
18858 case LWPNDIR:
18859
1/2
✓ Branch 0 taken 65038 times.
✗ Branch 1 not taken.
65038 if(0!=(s=checkLWpn(ri->lwpn,"Dir")))
18860 {
18861 65038 ((weapon*)s)->dir=(value/10000);
18862 65038 ((weapon*)s)->doAutoRotate(true);
18863 65038 }
18864
18865 65038 break;
18866
18867 case LWPNSPECIAL:
18868 if(0!=(s=checkLWpn(ri->lwpn,"Special")))
18869 ((weapon*)s)->specialinfo=(value/10000);
18870
18871 break;
18872
18873 case LWPNGRAVITY:
18874 if(0!=(s=checkLWpn(ri->lwpn,"Gravity")))
18875 {
18876 if(value)
18877 ((weapon*)s)->moveflags |= FLAG_OBEYS_GRAV;
18878 else
18879 ((weapon*)s)->moveflags &= ~FLAG_OBEYS_GRAV;
18880 }
18881 break;
18882
18883 case LWPNSTEP:
18884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8276 times.
8276 if(0!=(s=checkLWpn(ri->lwpn,"Step")))
18885 {
18886 // fp math is bad for replay, so always ignore this QR when replay is active.
18887 // TODO: can we just delete this QR? Would it actually break anything? For now,
18888 // just disable for replay and wait for more tests to be played with this QR
18889 // ignored.
18890
3/4
✓ Branch 0 taken 7031 times.
✓ Branch 1 taken 1245 times.
✓ Branch 2 taken 7031 times.
✗ Branch 3 not taken.
8276 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
18891 {
18892 8276 ((weapon*)s)->step= zslongToFix(value / 100);
18893 8276 }
18894 else
18895 {
18896 //old, buggy code replication, round two: Go! -Z
18897 //zfix val = zslongToFix(value);
18898 //val.doFloor();
18899 //((weapon*)s)->step = ((val / 100.0).getFloat());
18900
18901 //old, buggy code replication, round THREE: Go! -Z
18902 ((weapon*)s)->step = ((value/10000)/100.0);
18903 }
18904
18905 8276 }
18906
18907 8276 break;
18908
18909 case LWPNANGLE:
18910
1/2
✓ Branch 0 taken 1469 times.
✗ Branch 1 not taken.
1469 if(0!=(s=checkLWpn(ri->lwpn,"Angle")))
18911 {
18912 1469 ((weapon*)s)->angle=(double)(value/10000.0);
18913 1469 ((weapon*)(s))->doAutoRotate();
18914 1469 }
18915
18916 1469 break;
18917
18918 case LWPNDEGANGLE:
18919 if(0!=(s=checkLWpn(ri->lwpn,"DegAngle")))
18920 {
18921 double rangle = (value / 10000.0) * (PI / 180.0);
18922 ((weapon*)s)->angle=(double)(rangle);
18923 ((weapon*)(s))->doAutoRotate();
18924 }
18925
18926 break;
18927
18928 case LWPNVX:
18929 if(0!=(s=checkLWpn(ri->lwpn,"Vx")))
18930 {
18931 double vy;
18932 double vx = (value / 10000.0);
18933 if (((weapon*)(s))->angular)
18934 vy = zc::math::Sin(((weapon*)s)->angle)*((weapon*)s)->step;
18935 else
18936 {
18937 switch(NORMAL_DIR(((weapon*)(s))->dir))
18938 {
18939 case l_up:
18940 case r_up:
18941 case up:
18942 vy = -1.0*((weapon*)s)->step;
18943 break;
18944 case l_down:
18945 case r_down:
18946 case down:
18947 vy = ((weapon*)s)->step;
18948 break;
18949
18950 default:
18951 vy = 0;
18952 break;
18953 }
18954 }
18955 ((weapon*)s)->angular = true;
18956 ((weapon*)s)->angle=atan2(vy, vx);
18957 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
18958 ((weapon*)(s))->doAutoRotate();
18959 }
18960
18961 break;
18962
18963 case LWPNVY:
18964 if(0!=(s=checkLWpn(ri->lwpn,"Vy")))
18965 {
18966 double vx;
18967 double vy = (value / 10000.0);
18968 if (((weapon*)(s))->angular)
18969 vx = zc::math::Cos(((weapon*)s)->angle)*((weapon*)s)->step;
18970 else
18971 {
18972 switch(NORMAL_DIR(((weapon*)(s))->dir))
18973 {
18974 case l_up:
18975 case l_down:
18976 case left:
18977 vx = -1.0*((weapon*)s)->step;
18978 break;
18979 case r_down:
18980 case r_up:
18981 case right:
18982 vx = ((weapon*)s)->step;
18983 break;
18984
18985 default:
18986 vx = 0;
18987 break;
18988 }
18989 }
18990 ((weapon*)s)->angular = true;
18991 ((weapon*)s)->angle=atan2(vy, vx);
18992 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
18993 ((weapon*)(s))->doAutoRotate();
18994 }
18995
18996 break;
18997
18998 case LWPNANGULAR:
18999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1175 times.
1175 if(0!=(s=checkLWpn(ri->lwpn,"Angular")))
19000 {
19001 1175 ((weapon*)s)->angular=(value!=0);
19002 1175 ((weapon*)(s))->doAutoRotate(false, true);
19003 1175 }
19004
19005 1175 break;
19006
19007 case LWPNAUTOROTATE:
19008 if(0!=(s=checkLWpn(ri->lwpn,"AutoRotate")))
19009 {
19010 ((weapon*)s)->autorotate=(value!=0);
19011 ((weapon*)(s))->doAutoRotate(false, true);
19012 }
19013
19014 break;
19015
19016 case LWPNBEHIND:
19017 if(0!=(s=checkLWpn(ri->lwpn,"Behind")))
19018 ((weapon*)s)->behind=(value!=0);
19019
19020 break;
19021
19022 case LWPNDRAWTYPE:
19023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(0!=(s=checkLWpn(ri->lwpn,"DrawStyle")))
19024 49 ((weapon*)s)->drawstyle=(value/10000);
19025
19026 49 break;
19027
19028 case LWPNPOWER:
19029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69347 times.
69347 if(0!=(s=checkLWpn(ri->lwpn,"Damage")))
19030 69347 ((weapon*)s)->power=(value/10000);
19031
19032 69347 break;
19033 /*
19034 case LWPNRANGE:
19035 if(0!=(s=checkLWpn(ri->lwpn,"Range")))
19036 ((weapon*)s)->scriptrange=vbound((value/10000),0,512); //Allow it to move off-screen. -Z
19037 break;
19038 */
19039 case LWPNDEAD:
19040
2/2
✓ Branch 0 taken 132457 times.
✓ Branch 1 taken 6717 times.
139174 if(0!=(s=checkLWpn(ri->lwpn,"DeadState")))
19041 {
19042 132457 auto dead = value/10000;
19043 132457 ((weapon*)s)->dead=dead;
19044
2/2
✓ Branch 0 taken 68348 times.
✓ Branch 1 taken 64109 times.
132457 if(dead != 0) ((weapon*)s)->weapon_dying_frame = false;
19045 132457 }
19046 139174 break;
19047
19048 case LWPNID:
19049 if(0!=(s=checkLWpn(ri->lwpn,"ID")))
19050 ((weapon*)s)->id=(value/10000);
19051
19052 break;
19053
19054 case LWPNTILE:
19055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1853 times.
1853 if(0!=(s=checkLWpn(ri->lwpn,"Tile")))
19056 1853 ((weapon*)s)->tile=(value/10000);
19057
19058 1853 break;
19059
19060 case LWPNSCRIPTTILE:
19061 if(0!=(s=checkLWpn(ri->lwpn,"ScriptTile")))
19062 ((weapon*)s)->scripttile=vbound((value/10000),-1,NEWMAXTILES-1);
19063
19064 break;
19065
19066 case LWPNSCRIPTFLIP:
19067 if(0!=(s=checkLWpn(ri->lwpn,"ScriptFlip")))
19068 ((weapon*)s)->scriptflip=vbound((value/10000),-1,127);
19069
19070 break;
19071
19072 case LWPNCSET:
19073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2049 times.
2049 if(0!=(s=checkLWpn(ri->lwpn,"CSet")))
19074 2049 ((weapon*)s)->cs=(value/10000)&15;
19075
19076 2049 break;
19077
19078 case LWPNFLASHCSET:
19079 if(0!=(s=checkLWpn(ri->lwpn,"FlashCSet")))
19080 (((weapon*)s)->o_cset)|=(value/10000)<<4;
19081
19082 break;
19083
19084 case LWPNFRAMES:
19085
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(0!=(s=checkLWpn(ri->lwpn,"NumFrames")))
19086 404 ((weapon*)s)->frames=(value/10000);
19087
19088 404 break;
19089
19090 case LWPNFRAME:
19091 if(0!=(s=checkLWpn(ri->lwpn,"Frame")))
19092 ((weapon*)s)->aframe=(value/10000);
19093
19094 break;
19095
19096 case LWPNASPEED:
19097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(0!=(s=checkLWpn(ri->lwpn,"ASpeed")))
19098 457 ((weapon*)s)->o_speed=(value/10000);
19099
19100 457 break;
19101
19102 case LWPNFLASH:
19103 if(0!=(s=checkLWpn(ri->lwpn,"Flash")))
19104 ((weapon*)s)->flash=(value/10000);
19105
19106 break;
19107
19108 case LWPNFLIP:
19109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 683 times.
683 if(0!=(s=checkLWpn(ri->lwpn,"Flip")))
19110 683 ((weapon*)s)->flip=(value/10000);
19111
19112 683 break;
19113
19114 case LWPNROTATION:
19115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4922 times.
4922 if ( get_qr(qr_OLDSPRITEDRAWS) )
19116 {
19117 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
19118 "lweapon->Rotation");
19119 break;
19120 }
19121
1/2
✓ Branch 0 taken 4922 times.
✗ Branch 1 not taken.
4922 if(0!=(s=checkLWpn(ri->lwpn,"Rotation")))
19122 4922 ((weapon*)s)->rotation=(value/10000);
19123
19124 4922 break;
19125
19126 case LWPNEXTEND:
19127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(0!=(s=checkLWpn(ri->lwpn,"Extend")))
19128 16 ((weapon*)s)->extend=(value/10000);
19129
19130 16 break;
19131
19132 case LWPNOTILE:
19133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1841 times.
1841 if(0!=(s=checkLWpn(ri->lwpn,"OriginalTile")))
19134 {
19135 //zprint("LWPNOTILE before write: %d\n", ((weapon*)s)->o_tile);
19136 1841 ((weapon*)s)->o_tile=(value/10000);
19137 1841 ((weapon*)s)->ref_o_tile=(value/10000);
19138 //((weapon*)s)->script_wrote_otile=1; //Removing this as of 26th October, 2019 -Z
19139 //if at some future point we WANT writing ->Tile to also overwrite ->OriginalTile,
19140 //then either the user will need to manually write tile, or we can add a QR and
19141 // write ->tile here. 'script_wrote_otile' is out.
19142 //zprint("LWPNOTILE after write: %d\n", ((weapon*)s)->o_tile);
19143 1841 }
19144 1841 break;
19145
19146 case LWPNOCSET:
19147 if(0!=(s=checkLWpn(ri->lwpn,"OriginalCSet")))
19148 (((weapon*)s)->o_cset)|=(value/10000)&15;
19149
19150 break;
19151
19152 case LWPNHXOFS:
19153
1/2
✓ Branch 0 taken 60616 times.
✗ Branch 1 not taken.
60616 if(0!=(s=checkLWpn(ri->lwpn,"HitXOffset")))
19154 60616 (((weapon*)s)->hxofs)=(value/10000);
19155
19156 60616 break;
19157
19158 case LWPNHYOFS:
19159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60616 times.
60616 if(0!=(s=checkLWpn(ri->lwpn,"HitYOffset")))
19160 60616 (((weapon*)s)->hyofs)=(value/10000);
19161
19162 60616 break;
19163
19164 case LWPNXOFS:
19165
1/2
✓ Branch 0 taken 156 times.
✗ Branch 1 not taken.
156 if(0!=(s=checkLWpn(ri->lwpn,"DrawXOffset")))
19166 156 (((weapon*)s)->xofs)=(zfix)(value/10000);
19167
19168 156 break;
19169
19170 case LWPNYOFS:
19171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63470 times.
63470 if(0!=(s=checkLWpn(ri->lwpn,"DrawYOffset")))
19172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63470 times.
63470 (((weapon*)s)->yofs)=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19173
19174 63470 break;
19175
19176 case LWPNSHADOWXOFS:
19177 if(0!=(s=checkLWpn(ri->lwpn,"ShadowXOffset")))
19178 (((weapon*)s)->shadowxofs)=(zfix)(value/10000);
19179
19180 break;
19181
19182 case LWPNSHADOWYOFS:
19183 if(0!=(s=checkLWpn(ri->lwpn,"ShadowYOffset")))
19184 (((weapon*)s)->shadowyofs)=(zfix)(value/10000);
19185
19186 break;
19187
19188 case LWPNTOTALDYOFFS:
19189 break; //READ-ONLY
19190
19191 case LWPNZOFS:
19192 if(0!=(s=checkLWpn(ri->lwpn,"DrawZOffset")))
19193 (((weapon*)s)->zofs)=(zfix)(value/10000);
19194
19195 break;
19196
19197 case LWPNHXSZ:
19198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61740 times.
61740 if(0!=(s=checkLWpn(ri->lwpn,"HitWidth")))
19199 61740 (((weapon*)s)->hit_width)=(value/10000);
19200
19201 61740 break;
19202
19203 case LWPNHYSZ:
19204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61757 times.
61757 if(0!=(s=checkLWpn(ri->lwpn,"HitHeight")))
19205 61757 (((weapon*)s)->hit_height)=(value/10000);
19206
19207 61757 break;
19208
19209 case LWPNHZSZ:
19210 if(0!=(s=checkLWpn(ri->lwpn,"HitZHeight")))
19211 (((weapon*)s)->hzsz)=(value/10000);
19212
19213 break;
19214
19215 case LWPNTXSZ:
19216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(0!=(s=checkLWpn(ri->lwpn,"TileWidth")))
19217 10 (((weapon*)s)->txsz)=vbound((value/10000),1,20);
19218
19219 10 break;
19220
19221 case LWPNTYSZ:
19222
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(0!=(s=checkLWpn(ri->lwpn,"TileHeight")))
19223 10 (((weapon*)s)->tysz)=vbound((value/10000),1,20);
19224
19225 10 break;
19226
19227 case LWPNMISCD:
19228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497624 times.
497624 if(0!=(s=checkLWpn(ri->lwpn,"Misc")))
19229 {
19230 497624 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
19231 497624 (((weapon*)(s))->miscellaneous[a])=value;
19232 497624 }
19233
19234 497624 break;
19235
19236 case LWPNCOLLDET:
19237
1/2
✓ Branch 0 taken 16104 times.
✗ Branch 1 not taken.
16104 if(0!=(s=checkLWpn(ri->lwpn,"CollDetection")))
19238 16104 (((weapon*)(s))->scriptcoldet)=value/10000;
19239
19240 16104 break;
19241
19242 case LWPNENGINEANIMATE:
19243 if(0!=(s=checkLWpn(ri->lwpn,"Animation")))
19244 (((weapon*)(s))->do_animation)=(value ? 1 : 0);
19245
19246 break;
19247
19248 case LWPNPARENT:
19249 {
19250 //int32_t pitm = (vbound(value/10000,1,(MAXITEMS-1)));
19251 //zprint("Attempting to set ParentItem to: %d\n", pitm);
19252
19253 if(0!=(s=checkLWpn(ri->lwpn,"Parent")))
19254 (((weapon*)(s))->parentitem)=(vbound(value/10000,-1,(MAXITEMS-1)));
19255 break;
19256 }
19257
19258 case LWPNLEVEL:
19259 if(0!=(s=checkLWpn(ri->lwpn,"Level")))
19260 (((weapon*)(s))->type)=value/10000;
19261
19262 break;
19263
19264 case LWPNSCRIPT:
19265
1/2
✓ Branch 0 taken 60886 times.
✗ Branch 1 not taken.
60886 if(0!=(s=checkLWpn(ri->lwpn,"Script")))
19266 {
19267 60886 FFScript::deallocateAllScriptOwned(ScriptType::Lwpn, ri->lwpn);
19268 60886 (((weapon*)(s))->weaponscript)=vbound(value/10000,0,NUMSCRIPTWEAPONS-1);
19269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60886 times.
60886 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
19270 {
19271
2/2
✓ Branch 0 taken 487088 times.
✓ Branch 1 taken 60886 times.
547974 for(int32_t q=0; q<8; q++)
19272 487088 (((weapon*)(s))->weap_initd[q]) = 0;
19273 60886 }
19274 60886 }
19275 60886 break;
19276
19277 case LWPNUSEWEAPON:
19278
1/2
✓ Branch 0 taken 603 times.
✗ Branch 1 not taken.
603 if(0!=(s=checkLWpn(ri->lwpn,"Weapon")))
19279 603 (((weapon*)(s))->useweapon)=vbound(value/10000,0,255);
19280
19281 603 break;
19282
19283 case LWPNUSEDEFENCE:
19284 if(0!=(s=checkLWpn(ri->lwpn,"Defense")))
19285 (((weapon*)(s))->usedefence)=vbound(value/10000,0,255);
19286
19287 break;
19288
19289 case LWPNINITD:
19290 {
19291 206 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
19292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(0!=(s=checkLWpn(ri->lwpn,"InitD[]")))
19293 {
19294 206 (((weapon*)(s))->weap_initd[a])=value;
19295 206 }
19296 206 break;
19297 }
19298 case LWPNFALLCLK:
19299 if(0!=(s=checkLWpn(ri->lwpn,"Falling")))
19300 {
19301 if(((weapon*)(s))->fallclk != 0 && value == 0)
19302 {
19303 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
19304 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
19305 }
19306 else if(((weapon*)(s))->fallclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
19307 ((weapon*)(s))->fallclk = vbound(value/10000,0,70);
19308 }
19309 break;
19310 case LWPNFALLCMB:
19311 if(0!=(s=checkLWpn(ri->lwpn,"FallCombo")))
19312 {
19313 ((weapon*)(s))->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
19314 }
19315 break;
19316 case LWPNDROWNCLK:
19317 if(0!=(s=checkLWpn(ri->lwpn,"Drowning")))
19318 {
19319 if(((weapon*)(s))->drownclk != 0 && value == 0)
19320 {
19321 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
19322 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
19323 }
19324 else if(((weapon*)(s))->drownclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
19325 ((weapon*)(s))->drownclk = vbound(value/10000,0,70);
19326 }
19327 break;
19328 case LWPNDROWNCMB:
19329 if(0!=(s=checkLWpn(ri->lwpn,"DrownCombo")))
19330 {
19331 ((weapon*)(s))->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
19332 }
19333 break;
19334 case LWPNFAKEZ:
19335 if(0!=(s=checkLWpn(ri->lwpn,"FakeZ")))
19336 {
19337 ((weapon*)s)->fakez=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
19338 if(((weapon*)s)->fakez < 0) ((weapon*)s)->fakez = 0_zf;
19339 }
19340
19341 break;
19342
19343 case LWPNMOVEFLAGS:
19344 {
19345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
265 if(0!=(s=checkLWpn(ri->lwpn,"MoveFlags[]")))
19346 {
19347 265 int32_t indx = ri->d[rINDEX]/10000;
19348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
265 if(BC::checkBounds(indx, 0, 10, "lweapon->MoveFlags[]") == SH::_NoError)
19349 {
19350 //All bits, in order, of a single byte; just use bitwise
19351 265 int32_t bit = 1<<indx;
19352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
265 if(value)
19353 ((weapon*)(s))->moveflags |= bit;
19354 else
19355 265 ((weapon*)(s))->moveflags &= ~bit;
19356 265 }
19357 265 }
19358 265 break;
19359 }
19360 case LWPNFLAGS:
19361 {
19362 if(0!=(s=checkLWpn(ri->lwpn,"Flags[]")))
19363 {
19364 int32_t indx = ri->d[rINDEX]/10000;
19365 if(BC::checkBounds(indx, 0, WFLAG_MAX, "lweapon->Flags[]") == SH::_NoError)
19366 {
19367 //All bits, in order, of a single byte; just use bitwise
19368 int32_t bit = 1<<indx;
19369 if(value)
19370 ((weapon*)(s))->misc_wflags |= bit;
19371 else
19372 ((weapon*)(s))->misc_wflags &= ~bit;
19373 }
19374 }
19375 break;
19376 }
19377
19378 case LWPNGLOWRAD:
19379 if(0!=(s=checkLWpn(ri->lwpn,"LightRadius")))
19380 {
19381 ((weapon*)(s))->glowRad = vbound(value/10000,0,255);
19382 }
19383 break;
19384
19385 case LWPNGLOWSHP:
19386 if(0!=(s=checkLWpn(ri->lwpn,"LightShape")))
19387 {
19388 ((weapon*)(s))->glowShape = vbound(value/10000,0,255);
19389 }
19390 break;
19391
19392 case LWPNUNBL:
19393 if(0!=(s=checkLWpn(ri->lwpn,"Unblockable")))
19394 {
19395 ((weapon*)(s))->unblockable = (value/10000)&WPNUNB_ALL;
19396 }
19397 break;
19398
19399 case LWPNSHADOWSPR:
19400 if(0!=(s=checkLWpn(ri->lwpn,"ShadowSprite")))
19401 {
19402 ((weapon*)(s))->spr_shadow = vbound(value/10000, 0, 255);
19403 }
19404 break;
19405 case LWSWHOOKED:
19406 break; //read-only
19407 case LWPNTIMEOUT:
19408 if(0!=(s=checkLWpn(ri->lwpn,"Timeout")))
19409 {
19410 ((weapon*)(s))->weap_timeout = vbound(value/10000,0,214748);
19411 }
19412 break;
19413 case LWPNDEATHITEM:
19414 if(0!=(s=checkLWpn(ri->lwpn,"DeathItem")))
19415 {
19416 ((weapon*)(s))->death_spawnitem = vbound(value/10000,-1,MAXITEMS-1);
19417 }
19418 break;
19419 case LWPNDEATHDROPSET:
19420 if(0!=(s=checkLWpn(ri->lwpn,"DeathDropset")))
19421 {
19422 ((weapon*)(s))->death_spawndropset = vbound(value/10000,-1,MAXITEMDROPSETS-1);
19423 }
19424 break;
19425 case LWPNDEATHIPICKUP:
19426 if(0!=(s=checkLWpn(ri->lwpn,"DeathItemPFlags")))
19427 {
19428 ((weapon*)(s))->death_item_pflags = value/10000;
19429 }
19430 break;
19431 case LWPNDEATHSPRITE:
19432 if(0!=(s=checkLWpn(ri->lwpn,"DeathSprite")))
19433 {
19434 ((weapon*)(s))->death_sprite = vbound(value/10000,-255,MAXWPNS-1);
19435 }
19436 break;
19437 case LWPNDEATHSFX:
19438 if(0!=(s=checkLWpn(ri->lwpn,"DeathSFX")))
19439 {
19440 ((weapon*)(s))->death_sfx = vbound(value/10000,0,WAV_COUNT);
19441 }
19442 break;
19443 case LWPNLIFTLEVEL:
19444 if(0!=(s=checkLWpn(ri->lwpn,"LiftLevel")))
19445 {
19446 ((weapon*)(s))->lift_level = vbound(value/10000,0,255);
19447 }
19448 break;
19449 case LWPNLIFTTIME:
19450 if(0!=(s=checkLWpn(ri->lwpn,"LiftTime")))
19451 {
19452 ((weapon*)(s))->lift_time = vbound(value/10000,0,255);
19453 }
19454 break;
19455 case LWPNLIFTHEIGHT:
19456 if(0!=(s=checkLWpn(ri->lwpn,"LiftHeight")))
19457 {
19458 ((weapon*)(s))->lift_height = zslongToFix(value);
19459 }
19460 break;
19461
19462 ///----------------------------------------------------------------------------------------------------//
19463 //EWeapon Variables
19464 case EWPNSCALE:
19465 if ( get_qr(qr_OLDSPRITEDRAWS) )
19466 {
19467 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
19468 "eweapon->Scale");
19469 break;
19470 }
19471 if(0!=(s=checkEWpn(ri->ewpn,"Scale")))
19472 ((weapon*)s)->scale=(zfix)(value/100.0);
19473
19474 break;
19475
19476 case EWPNX:
19477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226569 times.
226569 if(0!=(s=checkEWpn(ri->ewpn,"X")))
19478
2/2
✓ Branch 0 taken 7282 times.
✓ Branch 1 taken 219287 times.
226569 ((weapon*)s)->x = (get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
19479
19480 226569 break;
19481
19482 case SPRITEMAXEWPN:
19483 {
19484 //No bounds check, as this is a universal function and works from NULL pointers!
19485 Ewpns.setMax(vbound((value/10000),1,MAX_EWPN_SPRITES));
19486 break;
19487 }
19488
19489 case EWPNY:
19490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226856 times.
226856 if(0!=(s=checkEWpn(ri->ewpn,"Y")))
19491
2/2
✓ Branch 0 taken 7170 times.
✓ Branch 1 taken 219686 times.
226856 ((weapon*)s)->y = (get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
19492
19493 226856 break;
19494
19495 case EWPNZ:
19496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6823 times.
6823 if(0!=(s=checkEWpn(ri->ewpn,"Z")))
19497 {
19498
2/2
✓ Branch 0 taken 1203 times.
✓ Branch 1 taken 5620 times.
6823 ((weapon*)s)->z=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
19499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6823 times.
6823 if(((weapon*)s)->z < 0) ((weapon*)s)->z = 0_zf;
19500 6823 }
19501
19502 6823 break;
19503
19504 case EWPNJUMP:
19505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6048 times.
6048 if(0!=(s=checkEWpn(ri->ewpn,"Jump")))
19506 6048 ((weapon*)s)->fall=zslongToFix(value)*-100;
19507
19508 6048 break;
19509
19510 case EWPNFAKEJUMP:
19511 if(0!=(s=checkEWpn(ri->ewpn,"FakeJump")))
19512 ((weapon*)s)->fakefall=zslongToFix(value)*-100;
19513
19514 break;
19515
19516 case EWPNDIR:
19517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138270 times.
138270 if(0!=(s=checkEWpn(ri->ewpn,"Dir")))
19518 {
19519 138270 ((weapon*)s)->dir=(value/10000);
19520 138270 ((weapon*)s)->doAutoRotate(true);
19521 138270 }
19522
19523 138270 break;
19524
19525 case EWPNLEVEL:
19526 if(0!=(s=checkEWpn(ri->ewpn,"Level")))
19527 ((weapon*)s)->type=(value/10000);
19528
19529 break;
19530
19531 case EWPNGRAVITY:
19532 if(0!=(s=checkEWpn(ri->ewpn,"Gravity")))
19533 {
19534 if(value)
19535 ((weapon*)s)->moveflags |= FLAG_OBEYS_GRAV;
19536 else
19537 ((weapon*)s)->moveflags &= ~FLAG_OBEYS_GRAV;
19538 }
19539 break;
19540
19541 case EWPNSTEP:
19542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264908 times.
264908 if(0!=(s=checkEWpn(ri->ewpn,"Step")))
19543 {
19544
3/4
✓ Branch 0 taken 243133 times.
✓ Branch 1 taken 21775 times.
✓ Branch 2 taken 243133 times.
✗ Branch 3 not taken.
264908 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
19545 {
19546 264908 ((weapon*)s)->step= zslongToFix(value / 100);
19547 264908 }
19548 else
19549 {
19550 //old, buggy code replication, round two: Go! -Z
19551 //zfix val = zslongToFix(value);
19552 //val.doFloor();
19553 //((weapon*)s)->step = ((val / 100.0).getFloat());
19554
19555 //old, buggy code replication, round THREE: Go! -Z
19556 ((weapon*)s)->step = ((value/10000)/100.0);
19557 //zprint2("ewpn step is %d\n", ((weapon*)s)->step);
19558 }
19559 264908 }
19560
19561 264908 break;
19562
19563 case EWPNANGLE:
19564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134925 times.
134925 if(0!=(s=checkEWpn(ri->ewpn,"Angle")))
19565 {
19566 134925 ((weapon*)s)->angle=(double)(value/10000.0);
19567 134925 ((weapon*)(s))->doAutoRotate();
19568 134925 }
19569
19570 134925 break;
19571
19572 case EWPNDEGANGLE:
19573 if(0!=(s=checkEWpn(ri->ewpn,"DegAngle")))
19574 {
19575 double rangle = (value / 10000.0) * (PI / 180.0);
19576 ((weapon*)s)->angle=(double)(rangle);
19577 ((weapon*)(s))->doAutoRotate();
19578 }
19579
19580 break;
19581
19582 case EWPNVX:
19583 if(0!=(s=checkEWpn(ri->ewpn,"Vx")))
19584 {
19585 double vy;
19586 double vx = (value / 10000.0);
19587 if (((weapon*)(s))->angular)
19588 vy = zc::math::Sin(((weapon*)s)->angle)*((weapon*)s)->step;
19589 else
19590 {
19591 switch(NORMAL_DIR(((weapon*)(s))->dir))
19592 {
19593 case l_up:
19594 case r_up:
19595 case up:
19596 vy = -1.0*((weapon*)s)->step;
19597 break;
19598 case l_down:
19599 case r_down:
19600 case down:
19601 vy = ((weapon*)s)->step;
19602 break;
19603
19604 default:
19605 vy = 0;
19606 break;
19607 }
19608 }
19609 ((weapon*)s)->angular = true;
19610 ((weapon*)s)->angle=atan2(vy, vx);
19611 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000;
19612 ((weapon*)(s))->doAutoRotate();
19613 }
19614
19615 break;
19616
19617 case EWPNVY:
19618 if(0!=(s=checkEWpn(ri->ewpn,"Vy")))
19619 {
19620 double vx;
19621 double vy = (value / 10000.0);
19622 if (((weapon*)(s))->angular)
19623 vx = zc::math::Cos(((weapon*)s)->angle)*((weapon*)s)->step;
19624 else
19625 {
19626 switch(NORMAL_DIR(((weapon*)(s))->dir))
19627 {
19628 case l_up:
19629 case l_down:
19630 case left:
19631 vx = -1.0*((weapon*)s)->step;
19632 break;
19633 case r_down:
19634 case r_up:
19635 case right:
19636 vx = ((weapon*)s)->step;
19637 break;
19638
19639 default:
19640 vx = 0;
19641 break;
19642 }
19643 }
19644 ((weapon*)s)->angular = true;
19645 ((weapon*)s)->angle=atan2(vy, vx);
19646 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000;
19647 ((weapon*)(s))->doAutoRotate();
19648 }
19649
19650 break;
19651
19652 case EWPNANGULAR:
19653
1/2
✓ Branch 0 taken 131702 times.
✗ Branch 1 not taken.
131702 if(0!=(s=checkEWpn(ri->ewpn,"Angular")))
19654 {
19655 131702 ((weapon*)s)->angular=(value!=0);
19656 131702 ((weapon*)(s))->doAutoRotate(false, true);
19657 131702 }
19658
19659 131702 break;
19660
19661 case EWPNAUTOROTATE:
19662 if(0!=(s=checkEWpn(ri->ewpn,"AutoRotate")))
19663 {
19664 ((weapon*)s)->autorotate=(value!=0);
19665 ((weapon*)(s))->doAutoRotate(false, true);
19666 }
19667
19668 break;
19669
19670 case EWPNBEHIND:
19671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(0!=(s=checkEWpn(ri->ewpn,"Behind")))
19672 47 ((weapon*)s)->behind=(value!=0);
19673
19674 47 break;
19675
19676 case EWPNDRAWTYPE:
19677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12175 times.
12175 if(0!=(s=checkEWpn(ri->ewpn,"DrawStyle")))
19678 12175 ((weapon*)s)->drawstyle=(value/10000);
19679
19680 12175 break;
19681
19682 case EWPNPOWER:
19683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132679 times.
132679 if(0!=(s=checkEWpn(ri->ewpn,"Damage")))
19684 132679 ((weapon*)s)->power=(value/10000);
19685
19686 132679 break;
19687
19688 case EWPNDEAD:
19689
1/2
✓ Branch 0 taken 23997 times.
✗ Branch 1 not taken.
23997 if(0!=(s=checkEWpn(ri->ewpn,"DeadState")))
19690 {
19691 23997 auto dead = value/10000;
19692 23997 ((weapon*)s)->dead=dead;
19693
2/2
✓ Branch 0 taken 15476 times.
✓ Branch 1 taken 8521 times.
23997 if(dead != 0) ((weapon*)s)->weapon_dying_frame = false;
19694 23997 }
19695
19696 23997 break;
19697
19698 case EWPNID:
19699 if(0!=(s=checkEWpn(ri->ewpn,"ID")))
19700 ((weapon*)s)->id=(value/10000);
19701
19702 break;
19703
19704 case EWPNTILE:
19705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9747 times.
9747 if(0!=(s=checkEWpn(ri->ewpn,"Tile")))
19706 9747 ((weapon*)s)->tile=(value/10000);
19707
19708 9747 break;
19709
19710 case EWPNSCRIPTTILE:
19711 if(0!=(s=checkEWpn(ri->ewpn,"ScriptTile")))
19712 ((weapon*)s)->scripttile=vbound((value/10000),-1, NEWMAXTILES-1);
19713
19714 break;
19715
19716 case EWPNSCRIPTFLIP:
19717 if(0!=(s=checkEWpn(ri->ewpn,"ScriptFlip")))
19718 ((weapon*)s)->scriptflip=vbound((value/10000),-1, 127);
19719
19720 break;
19721
19722 case EWPNCSET:
19723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2072 times.
2072 if(0!=(s=checkEWpn(ri->ewpn,"CSet")))
19724 2072 ((weapon*)s)->cs=(value/10000)&15;
19725
19726 2072 break;
19727
19728 case EWPNFLASHCSET:
19729 if(0!=(s=checkEWpn(ri->ewpn,"FlashCSet")))
19730 (((weapon*)s)->o_cset)|=(value/10000)<<4;
19731
19732 break;
19733
19734 case EWPNFRAMES:
19735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if(0!=(s=checkEWpn(ri->ewpn,"NumFrames")))
19736 41 ((weapon*)s)->frames=(value/10000);
19737
19738 41 break;
19739
19740 case EWPNFRAME:
19741 if(0!=(s=checkEWpn(ri->ewpn,"Frame")))
19742 ((weapon*)s)->aframe=(value/10000);
19743
19744 break;
19745
19746 case EWPNASPEED:
19747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if(0!=(s=checkEWpn(ri->ewpn,"ASpeed")))
19748 41 ((weapon*)s)->o_speed=(value/10000);
19749
19750 41 break;
19751
19752 case EWPNFLASH:
19753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
549 if(0!=(s=checkEWpn(ri->ewpn,"Flash")))
19754 549 ((weapon*)s)->flash=(value/10000);
19755
19756 549 break;
19757
19758 case EWPNFLIP:
19759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49622 times.
49622 if(0!=(s=checkEWpn(ri->ewpn,"Flip")))
19760 49622 ((weapon*)s)->flip=(value/10000);
19761
19762 49622 break;
19763
19764 case EWPNROTATION:
19765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1104 times.
1104 if ( get_qr(qr_OLDSPRITEDRAWS) )
19766 {
19767 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
19768 "eweapon->Rotation");
19769 break;
19770 }
19771
1/2
✓ Branch 0 taken 1104 times.
✗ Branch 1 not taken.
1104 if(0!=(s=checkEWpn(ri->ewpn,"Rotation")))
19772 1104 ((weapon*)s)->rotation=(value/10000);
19773
19774 1104 break;
19775
19776 case EWPNEXTEND:
19777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111461 times.
111461 if(0!=(s=checkEWpn(ri->ewpn,"Extend")))
19778 111461 ((weapon*)s)->extend=(value/10000);
19779
19780 111461 break;
19781
19782 case EWPNOTILE:
19783
1/2
✓ Branch 0 taken 4552 times.
✗ Branch 1 not taken.
4552 if(0!=(s=checkEWpn(ri->ewpn,"OriginalTile")))
19784 {
19785 4552 ((weapon*)s)->o_tile=(value/10000);
19786 4552 ((weapon*)s)->ref_o_tile=(value/10000);
19787 4552 }
19788
19789 4552 break;
19790
19791 case EWPNOCSET:
19792 if(0!=(s=checkEWpn(ri->ewpn,"OriginalCSet")))
19793 (((weapon*)s)->o_cset)|=(value/10000)&15;
19794
19795 break;
19796
19797 case EWPNHXOFS:
19798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138269 times.
138269 if(0!=(s=checkEWpn(ri->ewpn,"HitXOffset")))
19799 138269 (((weapon*)s)->hxofs)=(value/10000);
19800
19801 138269 break;
19802
19803 case EWPNHYOFS:
19804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137776 times.
137776 if(0!=(s=checkEWpn(ri->ewpn,"HitYOffset")))
19805 137776 (((weapon*)s)->hyofs)=(value/10000);
19806
19807 137776 break;
19808
19809 case EWPNXOFS:
19810
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 35366 times.
35370 if(0!=(s=checkEWpn(ri->ewpn,"DrawXOffset")))
19811 35366 (((weapon*)s)->xofs)=(zfix)(value/10000);
19812
19813 35370 break;
19814
19815 case EWPNYOFS:
19816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38448 times.
38448 if(0!=(s=checkEWpn(ri->ewpn,"DrawYOffset")))
19817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38448 times.
38448 (((weapon*)s)->yofs)=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19818
19819 38448 break;
19820 case EWPNTOTALDYOFFS:
19821 break; //READ-ONLY
19822
19823 case EWPNSHADOWXOFS:
19824 if(0!=(s=checkEWpn(ri->ewpn,"ShadowXOffset")))
19825 (((weapon*)s)->shadowxofs)=(zfix)(value/10000);
19826
19827 break;
19828
19829 case EWPNSHADOWYOFS:
19830 if(0!=(s=checkEWpn(ri->ewpn,"ShadowYOffset")))
19831 (((weapon*)s)->shadowyofs)=(zfix)(value/10000);
19832
19833 break;
19834
19835 case EWPNZOFS:
19836 if(0!=(s=checkEWpn(ri->ewpn,"DrawZOffset")))
19837 (((weapon*)s)->zofs)=(zfix)(value/10000);
19838
19839 break;
19840
19841 case EWPNHXSZ:
19842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234661 times.
234661 if(0!=(s=checkEWpn(ri->ewpn,"HitWidth")))
19843 234661 (((weapon*)s)->hit_width)=(value/10000);
19844
19845 234661 break;
19846
19847 case EWPNHYSZ:
19848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234074 times.
234074 if(0!=(s=checkEWpn(ri->ewpn,"HitHeight")))
19849 234074 (((weapon*)s)->hit_height)=(value/10000);
19850
19851 234074 break;
19852
19853 case EWPNHZSZ:
19854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(0!=(s=checkEWpn(ri->ewpn,"HitZHeight")))
19855 44 (((weapon*)s)->hzsz)=(value/10000);
19856
19857 44 break;
19858
19859 case EWPNTXSZ:
19860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111461 times.
111461 if(0!=(s=checkEWpn(ri->ewpn,"TileWidth")))
19861 111461 (((weapon*)s)->txsz)=vbound((value/10000),1,20);
19862
19863 111461 break;
19864
19865 case EWPNTYSZ:
19866
1/2
✓ Branch 0 taken 111461 times.
✗ Branch 1 not taken.
111461 if(0!=(s=checkEWpn(ri->ewpn,"TileHeight")))
19867 111461 (((weapon*)s)->tysz)=vbound((value/10000),1,20);
19868
19869 111461 break;
19870
19871 case EWPNMISCD:
19872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 910117 times.
910117 if(0!=(s=checkEWpn(ri->ewpn,"Misc")))
19873 {
19874 910117 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
19875 910117 (((weapon*)(s))->miscellaneous[a])=value;
19876 910117 }
19877
19878 910117 break;
19879
19880 case EWPNCOLLDET:
19881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20016 times.
20016 if(0!=(s=checkEWpn(ri->ewpn,"CollDetection")))
19882 20016 (((weapon*)(s))->scriptcoldet)=value/10000;
19883
19884 20016 break;
19885
19886 case EWPNENGINEANIMATE:
19887 if(0!=(s=checkEWpn(ri->ewpn,"Animation")))
19888 (((weapon*)(s))->do_animation)=(value ? 1 : 0);
19889
19890 break;
19891
19892
19893 case EWPNPARENTUID:
19894 if(0!=(s=checkEWpn(ri->ewpn, "ParentUID")))
19895 (((weapon*)(s))->parent_script_UID) = value; //literal, not *10000
19896 break;
19897
19898 case EWPNPARENT:
19899 if(0!=(s=checkEWpn(ri->ewpn, "Parent")))
19900 (((weapon*)(s))->parentid)= ( (get_qr(qr_OLDEWPNPARENT)) ? value / 10000 : value );
19901
19902 break;
19903
19904 case EWPNSCRIPT:
19905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1275 times.
1275 if(0!=(s=checkEWpn(ri->ewpn,"Script")))
19906 {
19907 1275 FFScript::deallocateAllScriptOwned(ScriptType::Ewpn, ri->ewpn);
19908 1275 (((weapon*)(s))->weaponscript)=vbound(value/10000,0,NUMSCRIPTWEAPONS-1);
19909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1275 times.
1275 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
19910 {
19911
2/2
✓ Branch 0 taken 10200 times.
✓ Branch 1 taken 1275 times.
11475 for(int32_t q=0; q<8; q++)
19912 10200 (((weapon*)(s))->weap_initd[q]) = 0;
19913 1275 }
19914 1275 }
19915 1275 break;
19916
19917 case EWPNINITD:
19918 {
19919 4214 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
19920
1/2
✓ Branch 0 taken 4214 times.
✗ Branch 1 not taken.
4214 if(0!=(s=checkEWpn(ri->ewpn,"InitD[]")))
19921 {
19922 4214 (((weapon*)(s))->weap_initd[a])=value;
19923 4214 }
19924 4214 break;
19925 }
19926 case EWPNFALLCLK:
19927 if(0!=(s=checkEWpn(ri->ewpn,"Falling")))
19928 {
19929 if(((weapon*)(s))->fallclk != 0 && value == 0)
19930 {
19931 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
19932 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
19933 }
19934 else if(((weapon*)(s))->fallclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
19935 ((weapon*)(s))->fallclk = vbound(value/10000,0,70);
19936 }
19937 break;
19938 case EWPNFALLCMB:
19939 if(0!=(s=checkEWpn(ri->ewpn,"FallCombo")))
19940 {
19941 ((weapon*)(s))->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
19942 }
19943 break;
19944 case EWPNDROWNCLK:
19945 if(0!=(s=checkEWpn(ri->ewpn,"Drowning")))
19946 {
19947 if(((weapon*)(s))->drownclk != 0 && value == 0)
19948 {
19949 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
19950 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
19951 }
19952 else if(((weapon*)(s))->drownclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
19953 ((weapon*)(s))->drownclk = vbound(value/10000,0,70);
19954 }
19955 break;
19956 case EWPNDROWNCMB:
19957 if(0!=(s=checkEWpn(ri->ewpn,"DrownCombo")))
19958 {
19959 ((weapon*)(s))->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
19960 }
19961 break;
19962 case EWPNFAKEZ:
19963 if(0!=(s=checkEWpn(ri->ewpn,"FakeZ")))
19964 {
19965 ((weapon*)s)->fakez=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
19966 if(((weapon*)s)->fakez < 0) ((weapon*)s)->fakez = 0_zf;
19967 }
19968
19969 break;
19970
19971 case EWPNMOVEFLAGS:
19972 {
19973 if(0!=(s=checkEWpn(ri->ewpn,"MoveFlags[]")))
19974 {
19975 int32_t indx = ri->d[rINDEX]/10000;
19976 if(BC::checkBounds(indx, 0, 10, "eweapon->MoveFlags[]") == SH::_NoError)
19977 {
19978 //All bits, in order, of a single byte; just use bitwise
19979 int32_t bit = 1<<indx;
19980 if(value)
19981 ((weapon*)(s))->moveflags |= bit;
19982 else
19983 ((weapon*)(s))->moveflags &= ~bit;
19984 }
19985 }
19986 break;
19987 }
19988 case EWPNFLAGS:
19989 {
19990 if(0!=(s=checkEWpn(ri->ewpn,"Flags[]")))
19991 {
19992 int32_t indx = ri->d[rINDEX]/10000;
19993 if(BC::checkBounds(indx, 0, WFLAG_MAX, "eweapon->Flags[]") == SH::_NoError)
19994 {
19995 //All bits, in order, of a single byte; just use bitwise
19996 int32_t bit = 1<<indx;
19997 if(value)
19998 ((weapon*)(s))->misc_wflags |= bit;
19999 else
20000 ((weapon*)(s))->misc_wflags &= ~bit;
20001 }
20002 }
20003 break;
20004 }
20005
20006 case EWPNGLOWRAD:
20007 if(0!=(s=checkEWpn(ri->ewpn,"LightRadius")))
20008 {
20009 ((weapon*)(s))->glowRad = vbound(value/10000,0,255);
20010 }
20011 break;
20012 case EWPNGLOWSHP:
20013 if(0!=(s=checkEWpn(ri->ewpn,"LightShape")))
20014 {
20015 ((weapon*)(s))->glowShape = vbound(value/10000,0,255);
20016 }
20017 break;
20018
20019 case EWPNUNBL:
20020 if(0!=(s=checkEWpn(ri->ewpn,"Unblockable")))
20021 {
20022 ((weapon*)(s))->unblockable = (value/10000)&WPNUNB_ALL;
20023 }
20024 break;
20025
20026 case EWPNSHADOWSPR:
20027 if(0!=(s=checkEWpn(ri->ewpn,"ShadowSprite")))
20028 {
20029 ((weapon*)(s))->spr_shadow = vbound(value/10000, 0, 255);
20030 }
20031 break;
20032 case EWSWHOOKED:
20033 break; //read-only
20034 case EWPNTIMEOUT:
20035 if(0!=(s=checkEWpn(ri->ewpn,"Timeout")))
20036 {
20037 ((weapon*)(s))->weap_timeout = vbound(value/10000,0,214748);
20038 }
20039 break;case EWPNDEATHITEM:
20040 if(0!=(s=checkEWpn(ri->ewpn,"DeathItem")))
20041 {
20042 ((weapon*)(s))->death_spawnitem = vbound(value/10000,-1,MAXITEMS-1);
20043 }
20044 break;
20045 case EWPNDEATHDROPSET:
20046 if(0!=(s=checkEWpn(ri->ewpn,"DeathDropset")))
20047 {
20048 ((weapon*)(s))->death_spawndropset = vbound(value/10000,-1,MAXITEMDROPSETS-1);
20049 }
20050 break;
20051 case EWPNDEATHIPICKUP:
20052 if(0!=(s=checkEWpn(ri->ewpn,"DeathItemPFlags")))
20053 {
20054 ((weapon*)(s))->death_item_pflags = value/10000;
20055 }
20056 break;
20057 case EWPNDEATHSPRITE:
20058 if(0!=(s=checkEWpn(ri->ewpn,"DeathSprite")))
20059 {
20060 ((weapon*)(s))->death_sprite = vbound(value/10000,-255,MAXWPNS-1);
20061 }
20062 break;
20063 case EWPNDEATHSFX:
20064 if(0!=(s=checkEWpn(ri->ewpn,"DeathSFX")))
20065 {
20066 ((weapon*)(s))->death_sfx = vbound(value/10000,0,WAV_COUNT);
20067 }
20068 break;
20069 case EWPNLIFTLEVEL:
20070 if(0!=(s=checkEWpn(ri->ewpn,"LiftLevel")))
20071 {
20072 ((weapon*)(s))->lift_level = vbound(value/10000,0,255);
20073 }
20074 break;
20075 case EWPNLIFTTIME:
20076 if(0!=(s=checkEWpn(ri->ewpn,"LiftTime")))
20077 {
20078 ((weapon*)(s))->lift_time = vbound(value/10000,0,255);
20079 }
20080 break;
20081 case EWPNLIFTHEIGHT:
20082 if(0!=(s=checkEWpn(ri->ewpn,"LiftHeight")))
20083 {
20084 ((weapon*)(s))->lift_height = zslongToFix(value);
20085 }
20086 break;
20087
20088 ///----------------------------------------------------------------------------------------------------//
20089 //NPC Variables
20090
20091 //Fixs are all a bit different
20092 case NPCX:
20093 {
20094
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1038284 times.
1038288 if(GuyH::loadNPC(ri->guyref, "npc->X") == SH::_NoError)
20095 {
20096
2/2
✓ Branch 0 taken 97206 times.
✓ Branch 1 taken 941078 times.
1038284 GuyH::getNPC()->x = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
20097
20098
1/2
✓ Branch 0 taken 1038284 times.
✗ Branch 1 not taken.
1038284 if(GuyH::hasHero())
20099 Hero.setXfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
20100 1038284 }
20101 }
20102 1038288 break;
20103
20104 case NPCSCALE:
20105 {
20106 if ( get_qr(qr_OLDSPRITEDRAWS) )
20107 {
20108 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
20109 "npc->Scale");
20110 break;
20111 }
20112 if(GuyH::loadNPC(ri->guyref, "npc->Scale") == SH::_NoError)
20113 {
20114 GuyH::getNPC()->scale = (value / 100.0);
20115 }
20116 }
20117 break;
20118
20119 case NPCIMMORTAL:
20120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(GuyH::loadNPC(ri->guyref, "npc->Immortal") == SH::_NoError)
20121 {
20122 3 GuyH::getNPC()->immortal = (value ? true : false);
20123 3 }
20124 3 break;
20125
20126 case NPCNOSLIDE:
20127 if(GuyH::loadNPC(ri->guyref, "npc->NoSlide") == SH::_NoError)
20128 {
20129 if(value)
20130 {
20131 GuyH::getNPC()->knockbackflags |= FLAG_NOSLIDE;
20132 }
20133 else
20134 {
20135 GuyH::getNPC()->knockbackflags &= ~FLAG_NOSLIDE;
20136 }
20137 }
20138 break;
20139
20140 case NPCNOSCRIPTKB:
20141 if(GuyH::loadNPC(ri->guyref, "npc->NoScriptKnockback") == SH::_NoError)
20142 {
20143 if(value)
20144 {
20145 GuyH::getNPC()->knockbackflags |= FLAG_NOSCRIPTKNOCKBACK;
20146 }
20147 else
20148 {
20149 GuyH::getNPC()->knockbackflags &= ~FLAG_NOSCRIPTKNOCKBACK;
20150 }
20151 }
20152 break;
20153
20154 case NPCKNOCKBACKSPEED:
20155 if(GuyH::loadNPC(ri->guyref, "npc->NoKnockback") == SH::_NoError)
20156 {
20157 GuyH::getNPC()->knockbackSpeed = vbound(value/10000, 0, 255);
20158 }
20159 break;
20160
20161 case SPRITEMAXNPC:
20162 {
20163 //No bounds check, as this is a universal function and works from NULL pointers!
20164 guys.setMax(vbound((value/10000),1,MAX_NPC_SPRITES));
20165 break;
20166 }
20167
20168 case NPCY:
20169 {
20170
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1042635 times.
1042699 if(GuyH::loadNPC(ri->guyref, "npc->Y") == SH::_NoError)
20171 {
20172 1042635 zfix oldy = GuyH::getNPC()->y;
20173
2/2
✓ Branch 0 taken 97206 times.
✓ Branch 1 taken 945429 times.
1042635 GuyH::getNPC()->y = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
20174
2/2
✓ Branch 0 taken 97206 times.
✓ Branch 1 taken 945429 times.
1042635 GuyH::getNPC()->floor_y += ((get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000)) - oldy);
20175
20176
1/2
✓ Branch 0 taken 1042635 times.
✗ Branch 1 not taken.
1042635 if(GuyH::hasHero())
20177 Hero.setYfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
20178 1042635 }
20179 }
20180 1042699 break;
20181
20182 case NPCZ:
20183 {
20184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970520 times.
970520 if(GuyH::loadNPC(ri->guyref, "npc->Z") == SH::_NoError)
20185 {
20186
2/2
✓ Branch 0 taken 1114 times.
✓ Branch 1 taken 969406 times.
970520 if(!never_in_air(GuyH::getNPC()->id))
20187 {
20188
1/2
✓ Branch 0 taken 969406 times.
✗ Branch 1 not taken.
969406 if(value < 0)
20189 GuyH::getNPC()->z = 0_zf;
20190 else
20191
2/2
✓ Branch 0 taken 97013 times.
✓ Branch 1 taken 872393 times.
969406 GuyH::getNPC()->z = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
20192
20193
1/2
✓ Branch 0 taken 969406 times.
✗ Branch 1 not taken.
969406 if(GuyH::hasHero())
20194 Hero.setZfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
20195 969406 }
20196 970520 }
20197 }
20198 970520 break;
20199
20200 case NPCJUMP:
20201 {
20202
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 973311 times.
973735 if(GuyH::loadNPC(ri->guyref, "npc->Jump") == SH::_NoError)
20203 {
20204
2/2
✓ Branch 0 taken 56049 times.
✓ Branch 1 taken 917262 times.
973311 if(canfall(GuyH::getNPC()->id))
20205 917262 GuyH::getNPC()->fall =zslongToFix(value)*-100;
20206
20207
1/2
✓ Branch 0 taken 973311 times.
✗ Branch 1 not taken.
973311 if(GuyH::hasHero())
20208 Hero.setFall(zslongToFix(value)*-100);
20209 973311 }
20210 }
20211 973735 break;
20212
20213 case NPCFAKEJUMP:
20214 {
20215 if(GuyH::loadNPC(ri->guyref, "npc->FakeJump") == SH::_NoError)
20216 {
20217 if(canfall(GuyH::getNPC()->id))
20218 GuyH::getNPC()->fakefall =zslongToFix(value)*-100;
20219
20220 if(GuyH::hasHero())
20221 Hero.setFakeFall(zslongToFix(value)*-100);
20222 }
20223 }
20224 break;
20225
20226 case NPCSTEP:
20227 {
20228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(GuyH::loadNPC(ri->guyref, "npc->Step") == SH::_NoError)
20229 {
20230
2/4
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
71 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
20231 {
20232 71 GuyH::getNPC()->step = zslongToFix(value / 100);
20233 71 }
20234 else
20235 {
20236 //old, buggy code replication, round two: Go! -Z
20237 //zfix val = zslongToFix(value);
20238 //val.doFloor();
20239 //GuyH::getNPC()->step = ((val / 100.0).getFloat());
20240
20241 //old, buggy code replication, round THREE: Go! -Z
20242 GuyH::getNPC()->step = ((value/10000)/100.0);
20243 }
20244 71 }
20245 }
20246 71 break;
20247
20248 case NPCGRAVITY:
20249 {
20250 if(GuyH::loadNPC(ri->guyref, "npc->Gravity") == SH::_NoError)
20251 {
20252 if(value)
20253 GuyH::getNPC()->moveflags |= FLAG_OBEYS_GRAV;
20254 else
20255 GuyH::getNPC()->moveflags &= ~FLAG_OBEYS_GRAV;
20256 }
20257 }
20258 break;
20259
20260 case NPCXOFS:
20261 {
20262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21269 times.
21269 if(GuyH::loadNPC(ri->guyref, "npc->DrawXOffset") == SH::_NoError)
20263 21269 GuyH::getNPC()->xofs = zfix(value / 10000);
20264 }
20265 21269 break;
20266
20267 case NPCYOFS:
20268 {
20269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28037 times.
28037 if(GuyH::loadNPC(ri->guyref, "npc->DrawYOffset") == SH::_NoError)
20270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28037 times.
28037 GuyH::getNPC()->yofs = zfix(value / 10000) + (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
20271 }
20272 28037 break;
20273
20274 case NPCSHADOWXOFS:
20275 {
20276 if(GuyH::loadNPC(ri->guyref, "npc->ShadowXOffset") == SH::_NoError)
20277 GuyH::getNPC()->shadowxofs = zfix(value / 10000);
20278 }
20279 break;
20280
20281 case NPCSHADOWYOFS:
20282 {
20283 if(GuyH::loadNPC(ri->guyref, "npc->ShadowYOffset") == SH::_NoError)
20284 GuyH::getNPC()->shadowyofs = zfix(value / 10000);
20285 }
20286 break;
20287
20288 case NPCTOTALDYOFFS:
20289 break; //READ-ONLY
20290
20291 case NPCROTATION:
20292 {
20293 if ( get_qr(qr_OLDSPRITEDRAWS) )
20294 {
20295 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
20296 "npc->Rotation");
20297 break;
20298 }
20299 if(GuyH::loadNPC(ri->guyref, "npc->Rotation") == SH::_NoError)
20300 GuyH::getNPC()->rotation = (value / 10000);
20301 }
20302 break;
20303
20304 case NPCZOFS:
20305 {
20306 if(GuyH::loadNPC(ri->guyref, "npc->DrawZOffset") == SH::_NoError)
20307 GuyH::getNPC()->zofs = zfix(value / 10000);
20308 }
20309 break;
20310
20311 #define SET_NPC_VAR_INT(member, str) \
20312 { \
20313 if(GuyH::loadNPC(ri->guyref, str) == SH::_NoError) \
20314 GuyH::getNPC()->member = value / 10000; \
20315 }
20316
20317
20318 case NPCISCORE:
20319 if(GuyH::loadNPC(ri->guyref, "npc->isCore") == SH::_NoError)
20320 GuyH::getNPC()->isCore = ( (value / 10000) ? true : false );
20321 break;
20322
20323
20324 case NPCDIR:
20325
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1046411 times.
1046835 SET_NPC_VAR_INT(dir, "npc->Dir") break;
20326
20327 case NPCHITDIR:
20328 if(GuyH::loadNPC(ri->guyref, "npc->HitDir") != SH::_NoError)
20329 (GuyH::getNPC()->hitdir) = vbound(value/10000, 0, 3);
20330
20331 break;
20332
20333 case NPCSLIDECLK:
20334 if(GuyH::loadNPC(ri->guyref, "npc->SlideClock") != SH::_NoError)
20335 GuyH::getNPC()->sclk = value/10000;//vbound(value/10000,0,255);
20336
20337 break;
20338
20339 case NPCFADING:
20340 if(GuyH::loadNPC(ri->guyref, "npc->Fading") != SH::_NoError)
20341 (GuyH::getNPC()->fading) = vbound(value/10000,0,4);
20342
20343 break;
20344
20345 case NPCHALTCLK:
20346 if(GuyH::loadNPC(ri->guyref, "npc->Halt") != SH::_NoError)
20347 (GuyH::getNPC()->clk2) = vbound(value/10000,0,214748);
20348
20349 break;
20350
20351 case NPCFRAME:
20352 if(GuyH::loadNPC(ri->guyref, "npc->Frame") != SH::_NoError)
20353 (GuyH::getNPC()->clk2) = vbound(value/10000,0,214748);
20354
20355 break;
20356
20357 case NPCMOVESTATUS:
20358 if(GuyH::loadNPC(ri->guyref, "npc->MoveStatus") != SH::_NoError)
20359 (GuyH::getNPC()->movestatus) = vbound(value/10000,0,3);
20360
20361 break;
20362
20363 case NPCRATE:
20364 SET_NPC_VAR_INT(rate, "npc->Rate") break;
20365
20366 case NPCHOMING:
20367 SET_NPC_VAR_INT(homing, "npc->Homing") break;
20368
20369 case NPCFRAMERATE:
20370 SET_NPC_VAR_INT(frate, "npc->ASpeed") break;
20371
20372 case NPCHALTRATE:
20373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 SET_NPC_VAR_INT(hrate, "npc->HaltRate") break;
20374
20375 case NPCRANDOM:
20376 SET_NPC_VAR_INT(rate, "npc->Random") break;
20377
20378 case NPCDRAWTYPE:
20379
1/2
✓ Branch 0 taken 4414 times.
✗ Branch 1 not taken.
4414 SET_NPC_VAR_INT(drawstyle, "npc->DrawStyle") break;
20380
20381 case NPCHP:
20382
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 1033702 times.
1034127 SET_NPC_VAR_INT(hp, "npc->HP") break;
20383
20384 case NPCORIGINALHP:
20385 SET_NPC_VAR_INT(starting_hp, "npc->OriginalHP") break;
20386
20387 //case NPCID: SET_NPC_VAR_INT(id, "npc->ID") break; ~Disallowed
20388 case NPCDP:
20389
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 784 times.
788 SET_NPC_VAR_INT(dp, "npc->Damage") break;
20390
20391 case NPCTYPE:
20392 {
20393 SET_NPC_VAR_INT(family, "npc->Type") break;
20394 }
20395
20396 case NPCWDP:
20397
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 317 times.
321 SET_NPC_VAR_INT(wdp, "npc->WeaponDamage") break;
20398
20399 case NPCITEMSET:
20400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 SET_NPC_VAR_INT(item_set, "npc->ItemSet") break;
20401
20402 case NPCBOSSPAL:
20403 SET_NPC_VAR_INT(bosspal, "npc->BossPal") break;
20404
20405 case NPCBGSFX:
20406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(GuyH::loadNPC(ri->guyref, "npc->SFX") == SH::_NoError)
20407 {
20408 13 enemy *en=GuyH::getNPC();
20409 13 int32_t newSFX = value / 10000;
20410
20411 // Stop the old sound and start the new one
20412
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(en->bgsfx != newSFX)
20413 {
20414 2 en->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
20415 2 cont_sfx(newSFX);
20416 2 en->bgsfx = newSFX;
20417 2 }
20418 13 }
20419 13 break;
20420
20421
20422 case NPCEXTEND:
20423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77612 times.
77612 SET_NPC_VAR_INT(extend, "npc->Extend") break;
20424
20425 case NPCHXOFS:
20426
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 749 times.
1181 SET_NPC_VAR_INT(hxofs, "npc->HitXOffset") break;
20427
20428 case NPCHYOFS:
20429
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 3751 times.
4183 SET_NPC_VAR_INT(hyofs, "npc->HitYOffset") break;
20430
20431 case NPCHXSZ:
20432
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 6636 times.
7068 SET_NPC_VAR_INT(hit_width, "npc->HitWidth") break;
20433
20434 case NPCHYSZ:
20435
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 6636 times.
7068 SET_NPC_VAR_INT(hit_height, "npc->HitHeight") break;
20436
20437 case NPCHZSZ:
20438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 SET_NPC_VAR_INT(hzsz, "npc->HitZHeight") break;
20439
20440 case NPCCOLLDET:
20441
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 28755 times.
28759 SET_NPC_VAR_INT(scriptcoldet, "npc->CollDetection") break;
20442
20443 case NPCENGINEANIMATE:
20444 SET_NPC_VAR_INT(do_animation, "npc->Animation") break;
20445
20446 case NPCSTUN:
20447
1/2
✓ Branch 0 taken 1094 times.
✗ Branch 1 not taken.
1094 SET_NPC_VAR_INT(stunclk, "npc->Stun") break;
20448
20449 case NPCHUNGER:
20450 SET_NPC_VAR_INT(grumble, "npc->Hunger") break;
20451
20452 case NPCWEAPSPRITE:
20453 SET_NPC_VAR_INT(wpnsprite, "npc->WeaponSprite") break;
20454
20455 case NPCCSET:
20456 {
20457
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 1020071 times.
1020506 if(GuyH::loadNPC(ri->guyref, "npc->CSet") == SH::_NoError)
20458 {
20459 1020071 GuyH::getNPC()->cs = (value / 10000) & 0xF;
20460
1/2
✓ Branch 0 taken 1020071 times.
✗ Branch 1 not taken.
1020071 if(GuyH::getNPC()->family == eeLEV) GuyH::getNPC()->dcset = (value / 10000) & 0xF;
20461 1020071 }
20462 }
20463 1020506 break;
20464
20465 //Bounds on value
20466 case NPCTXSZ:
20467 {
20468 10539 int32_t height = value / 10000;
20469
20470
3/4
✓ Branch 0 taken 10103 times.
✓ Branch 1 taken 436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10103 times.
10539 if(GuyH::loadNPC(ri->guyref, "npc->TileWidth") == SH::_NoError &&
20471 10103 BC::checkBounds(height, 0, 20, "npc->TileWidth") == SH::_NoError)
20472 10103 GuyH::getNPC()->txsz = height;
20473 }
20474 10539 break;
20475
20476 case NPCTYSZ:
20477 {
20478 10539 int32_t width = value / 10000;
20479
20480
3/4
✓ Branch 0 taken 10103 times.
✓ Branch 1 taken 436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10103 times.
10539 if(GuyH::loadNPC(ri->guyref, "npc->TileHeight") == SH::_NoError &&
20481 10103 BC::checkBounds(width, 0, 20, "npc->TileHeight") == SH::_NoError)
20482 10103 GuyH::getNPC()->tysz = width;
20483 }
20484 10539 break;
20485
20486 case NPCOTILE:
20487 {
20488 8696 int32_t tile = value / 10000;
20489
20490
3/4
✓ Branch 0 taken 8689 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8689 times.
8696 if(GuyH::loadNPC(ri->guyref, "npc->OriginalTile") == SH::_NoError &&
20491 8689 BC::checkTile(tile, "npc->OriginalTile") == SH::_NoError)
20492 8689 GuyH::getNPC()->o_tile = tile;
20493 }
20494 8696 break;
20495
20496 case NPCTILE:
20497 {
20498 4912 int32_t tile = value / 10000;
20499
20500
2/4
✓ Branch 0 taken 4912 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4912 times.
4912 if(GuyH::loadNPC(ri->guyref, "npc->Tile") == SH::_NoError &&
20501 4912 BC::checkTile(tile, "npc->Tile") == SH::_NoError)
20502 4912 GuyH::getNPC()->tile = tile;
20503 }
20504 4912 break;
20505
20506 case NPCSCRIPTTILE:
20507 {
20508 if(GuyH::loadNPC(ri->guyref, "npc->ScriptTile") == SH::_NoError)
20509 GuyH::getNPC()->scripttile = vbound((value/10000),-1, NEWMAXTILES-1);
20510 }
20511 break;
20512
20513 case NPCSCRIPTFLIP:
20514 {
20515 if(GuyH::loadNPC(ri->guyref, "npc->ScriptFlip") == SH::_NoError )
20516 GuyH::getNPC()->scriptflip = vbound(value/10000, -1, 127);
20517 }
20518 break;
20519
20520 case NPCWEAPON:
20521 {
20522 int32_t weapon = value / 10000;
20523
20524 if(GuyH::loadNPC(ri->guyref, "npc->Weapon") == SH::_NoError &&
20525 BC::checkBounds(weapon, 0, MAXWPNS-1, "npc->Weapon") == SH::_NoError)
20526 {
20527 GuyH::getNPC()->wpn = weapon;
20528
20529 //al_trace("Correct weapon sprite is: %d /n", FFCore.GetDefaultWeaponSprite(weapon));
20530 if ( get_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE) ) //this should probably just be an extra_rule
20531 {
20532 GuyH::getNPC()->wpnsprite = FFCore.GetDefaultWeaponSprite(weapon);
20533 }
20534 //else GuyH::getNPC()->wpnsprite = FFCore.GetDefaultWeaponSprite(weapon); //just to test that this works.
20535 }
20536 }
20537 break;
20538
20539 //Indexed
20540 case NPCDEFENSED:
20541 {
20542 545362 int32_t a = ri->d[rINDEX] / 10000;
20543
20544
2/4
✓ Branch 0 taken 545362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 545362 times.
545362 if(GuyH::loadNPC(ri->guyref, "npc->Defense") == SH::_NoError &&
20545 545362 BC::checkBounds(a, 0, (edefLAST255), "npc->Defense") == SH::_NoError)
20546 {
20547
4/4
✓ Branch 0 taken 545278 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 521697 times.
✓ Branch 3 taken 23581 times.
545362 if ( ( get_qr(qr_250WRITEEDEFSCRIPT) ) && a == edefSCRIPT )
20548 {
20549
2/2
✓ Branch 0 taken 235810 times.
✓ Branch 1 taken 23581 times.
259391 for ( int32_t sd = edefSCRIPT01; sd <= edefSCRIPT10; sd++ )
20550 {
20551 235810 GuyH::getNPC()->defense[sd] = vbound((value / 10000),0,255);
20552 235810 }
20553 23581 }
20554 //no else here, is intentional as a fallthrough. -Z
20555 545362 GuyH::getNPC()->defense[a] = vbound((value / 10000),0,255);
20556 545362 }
20557 }
20558 545362 break;
20559
20560 case NPCPARENTUID:
20561 if(GuyH::loadNPC(ri->guyref, "npc->ParentUID") == SH::_NoError)
20562 {
20563 GuyH::getNPC()->parent_script_UID = value; //literal, not *10000
20564 }
20565 break;
20566
20567 case NPCHITBY:
20568 {
20569 int32_t indx = ri->d[rINDEX] / 10000;
20570
20571 if(GuyH::loadNPC(ri->guyref, "npc->HitBy[]") == SH::_NoError)
20572 {
20573 switch(indx)
20574 {
20575 //screen index objects
20576 case 0:
20577 case 1:
20578 case 2:
20579 case 3:
20580 case 8:
20581 case 9:
20582 case 10:
20583 case 11:
20584 case 12:
20585 case 16:
20586 {
20587 GuyH::getNPC()->hitby[indx] = vbound((value / 10000),0,255); //Once again, why did I vbound this, and why did I allow it to be written? UIDs are LONGs, with a starting value of 0.0001. -Z
20588 break;
20589 }
20590 //UIDs
20591 case 4:
20592 case 5:
20593 case 6:
20594 case 7:
20595 case 13:
20596 case 14:
20597 case 15:
20598 {
20599 GuyH::getNPC()->hitby[indx] = value; //Once again, why did I vbound this, and why did I allow it to be written? UIDs are LONGs, with a starting value of 0.0001. -Z
20600 break;
20601 }
20602 default: al_trace("Invalid index used with npc->hitBy[%d]. /n", indx); break;
20603 }
20604 }
20605 break;
20606 }
20607
20608 //2.future compat. -Z
20609
20610
20611 case NPCSCRDEFENSED:
20612 {
20613 int32_t a = ri->d[rINDEX] / 10000;
20614
20615 if(GuyH::loadNPC(ri->guyref, "npc->ScriptDefense") == SH::_NoError &&
20616 BC::checkBounds(a, 0, edefSCRIPTDEFS_MAX, "npc->ScriptDefense") == SH::_NoError)
20617 GuyH::getNPC()->defense[a+edefSCRIPT01] = value / 10000;
20618 }
20619 break;
20620
20621 case NPCMISCD:
20622 {
20623 2614735 int32_t a = ri->d[rINDEX] / 10000;
20624
20625
3/4
✓ Branch 0 taken 2614696 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2614696 times.
2614735 if(GuyH::loadNPC(ri->guyref, "npc->Misc") == SH::_NoError &&
20626 2614696 BC::checkMisc32(a, "npc->Misc") == SH::_NoError)
20627 2614696 GuyH::getNPC()->miscellaneous[a] = value;
20628
20629 }
20630
20631 2614735 break;
20632
20633 case NPCINITD:
20634 {
20635 int32_t a = ri->d[rINDEX] / 10000;
20636
20637 if(GuyH::loadNPC(ri->guyref, "npc->InitD[]") == SH::_NoError)
20638 {
20639 //enemy *e = (enemy*)guys.spr(ri->guyref);
20640 //e->initD[a] = value;
20641 GuyH::getNPC()->initD[a] = value;
20642 }
20643 }
20644 break;
20645
20646 case NPCSCRIPT:
20647 {
20648 if(GuyH::loadNPC(ri->guyref, "npc->Script") == SH::_NoError)
20649 {
20650 FFScript::deallocateAllScriptOwned(ScriptType::NPC, ri->guyref);
20651 //enemy *e = (enemy*)guys.spr(ri->guyref);
20652 //e->initD[a] = value;
20653 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
20654 {
20655 for(int32_t q=0; q<8; q++)
20656 GuyH::getNPC()->initD[q] = 0;
20657 }
20658 GuyH::getNPC()->script = vbound((value/10000), 0, NUMSCRIPTGUYS-1);
20659 }
20660 }
20661 break;
20662
20663 //npc->Attributes[] setter -Z
20664 case NPCDD:
20665 {
20666 int32_t a = ri->d[rINDEX] / 10000;
20667
20668 if(GuyH::loadNPC(ri->guyref, "npc->Attributes") == SH::_NoError &&
20669 BC::checkBounds(a, 0, 31, "npc->Attributes") == SH::_NoError)
20670
20671 switch(a)
20672 {
20673 case 0: GuyH::getNPC()->dmisc1 = value / 10000; break;
20674 case 1: GuyH::getNPC()->dmisc2 = value / 10000; break;
20675 case 2: GuyH::getNPC()->dmisc3 = value / 10000; break;
20676 case 3: GuyH::getNPC()->dmisc4 = value / 10000; break;
20677 case 4: GuyH::getNPC()->dmisc5 = value / 10000; break;
20678 case 5: GuyH::getNPC()->dmisc6 = value / 10000; break;
20679 case 6: GuyH::getNPC()->dmisc7 = value / 10000; break;
20680 case 7: GuyH::getNPC()->dmisc8 = value / 10000; break;
20681 case 8: GuyH::getNPC()->dmisc9 = value / 10000; break;
20682 case 9: GuyH::getNPC()->dmisc10 = value / 10000; break;
20683 case 10: GuyH::getNPC()->dmisc11 = value / 10000; break;
20684 case 11: GuyH::getNPC()->dmisc12 = value / 10000; break;
20685 case 12: GuyH::getNPC()->dmisc13 = value / 10000; break;
20686 case 13: GuyH::getNPC()->dmisc14 = value / 10000; break;
20687 case 14: GuyH::getNPC()->dmisc15 = value / 10000; break;
20688 case 15: GuyH::getNPC()->dmisc16 = value / 10000; break;
20689 case 16: GuyH::getNPC()->dmisc17 = value / 10000; break;
20690 case 17: GuyH::getNPC()->dmisc18 = value / 10000; break;
20691 case 18: GuyH::getNPC()->dmisc19 = value / 10000; break;
20692 case 19: GuyH::getNPC()->dmisc20 = value / 10000; break;
20693 case 20: GuyH::getNPC()->dmisc21 = value / 10000; break;
20694 case 21: GuyH::getNPC()->dmisc22 = value / 10000; break;
20695 case 22: GuyH::getNPC()->dmisc23 = value / 10000; break;
20696 case 23: GuyH::getNPC()->dmisc24 = value / 10000; break;
20697 case 24: GuyH::getNPC()->dmisc25 = value / 10000; break;
20698 case 25: GuyH::getNPC()->dmisc26 = value / 10000; break;
20699 case 26: GuyH::getNPC()->dmisc27 = value / 10000; break;
20700 case 27: GuyH::getNPC()->dmisc28 = value / 10000; break;
20701 case 28: GuyH::getNPC()->dmisc28 = value / 10000; break;
20702 case 29: GuyH::getNPC()->dmisc30 = value / 10000; break;
20703 case 30: GuyH::getNPC()->dmisc31 = value / 10000; break;
20704 case 31: GuyH::getNPC()->dmisc32 = value / 10000; break;
20705 default: break;
20706 }
20707 break;
20708 }
20709
20710
20711 case NPCINVINC:
20712 {
20713 if(GuyH::loadNPC(ri->guyref, "npc->InvFrames") == SH::_NoError)
20714 GuyH::getNPC()->hclk = (int32_t)value/10000;
20715 }
20716 break;
20717
20718 case NPCSUPERMAN:
20719 {
20720 if(GuyH::loadNPC(ri->guyref, "npc->Invincible") == SH::_NoError)
20721 GuyH::getNPC()->superman = (int32_t)value/10000;
20722 }
20723 break;
20724
20725 case NPCHASITEM:
20726 {
20727 if(GuyH::loadNPC(ri->guyref, "npc->HasItem") == SH::_NoError)
20728 GuyH::getNPC()->itemguy = (value/10000)?1:0;
20729 }
20730 break;
20731
20732 case NPCRINGLEAD:
20733 {
20734 if(GuyH::loadNPC(ri->guyref, "npc->Ringleader") == SH::_NoError)
20735 GuyH::getNPC()->leader = (value/10000)?1:0;
20736 }
20737 break;
20738
20739 case NPCSHIELD:
20740 {
20741 int32_t indx = ri->d[rINDEX];
20742 if(GuyH::loadNPC(ri->guyref, "npc->Shield[]") == SH::_NoError)
20743 {
20744 switch(indx)
20745 {
20746 case 0:
20747 {
20748 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_front) : (GuyH::getNPC()->flags &= ~inv_front);
20749 break;
20750 }
20751 case 1:
20752 {
20753 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_left) : (GuyH::getNPC()->flags &= ~inv_left);
20754 break;
20755 }
20756 case 2:
20757 {
20758 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_right) : (GuyH::getNPC()->flags &= ~inv_right);
20759 break;
20760 }
20761 case 3:
20762 {
20763 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_back) : (GuyH::getNPC()->flags &= ~inv_back);
20764 break;
20765 }
20766 case 4: //shield can be broken
20767 {
20768 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= guy_bkshield) : (GuyH::getNPC()->flags &= ~guy_bkshield);
20769 break;
20770 }
20771 default:
20772 {
20773 Z_scripterrlog("Invalid Array Index passed to npc->Shield[]: %d\n", indx);
20774 break;
20775 }
20776 }
20777 }
20778 }
20779 break;
20780
20781 case NPCFROZENTILE:
20782 SET_NPC_VAR_INT(frozentile, "npc->FrozenTile"); break;
20783 case NPCFROZENCSET:
20784 SET_NPC_VAR_INT(frozencset, "npc->FrozenCSet"); break;
20785 case NPCFROZEN:
20786 SET_NPC_VAR_INT(frozenclock, "npc->Frozen"); break;
20787
20788 case NPCBEHAVIOUR:
20789 {
20790 if(GuyH::loadNPC(ri->guyref, "npc->Behaviour[]") != SH::_NoError)
20791 {
20792 break;
20793 }
20794 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
20795 switch(index)
20796 {
20797 case 0:
20798 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG1 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG1;
20799 break;
20800 case 1:
20801 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG2 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG2;
20802 break;
20803 case 2:
20804 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG3 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG3;
20805 break;
20806 case 3:
20807 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG4 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG4;
20808 break;
20809 case 4:
20810 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG5 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG5;
20811 break;
20812 case 5:
20813 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG6 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG6;
20814 break;
20815 case 6:
20816 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG7 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG7;
20817 break;
20818 case 7:
20819 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG8 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG8;
20820 break;
20821 case 8:
20822 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG9 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG9;
20823 break;
20824 case 9:
20825 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG10 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG10;
20826 break;
20827 case 10:
20828 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG11 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG11;
20829 break;
20830 case 11:
20831 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG12 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG12;
20832 break;
20833 case 12:
20834 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG13 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG13;
20835 break;
20836 case 13:
20837 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG14 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG14;
20838 break;
20839 case 14:
20840 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG15 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG15;
20841 break;
20842 case 15:
20843 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG16 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG16;
20844 break;
20845
20846
20847 default:
20848 break;
20849 }
20850
20851 break;
20852 }
20853 case NPCFALLCLK:
20854 if(GuyH::loadNPC(ri->guyref, "npc->Falling") == SH::_NoError)
20855 {
20856 if(GuyH::getNPC()->fallclk != 0 && value == 0)
20857 {
20858 GuyH::getNPC()->cs = GuyH::getNPC()->old_cset;
20859 GuyH::getNPC()->tile = GuyH::getNPC()->o_tile;
20860 }
20861 else if(GuyH::getNPC()->fallclk == 0 && value != 0) GuyH::getNPC()->old_cset = GuyH::getNPC()->cs;
20862 GuyH::getNPC()->fallclk = vbound(value/10000,0,70);
20863 }
20864 break;
20865 case NPCFALLCMB:
20866 if(GuyH::loadNPC(ri->guyref, "npc->FallCombo") == SH::_NoError)
20867 {
20868 GuyH::getNPC()->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
20869 }
20870 break;
20871 case NPCDROWNCLK:
20872 if(GuyH::loadNPC(ri->guyref, "npc->Drowning") == SH::_NoError)
20873 {
20874 if(GuyH::getNPC()->drownclk != 0 && value == 0)
20875 {
20876 GuyH::getNPC()->cs = GuyH::getNPC()->old_cset;
20877 GuyH::getNPC()->tile = GuyH::getNPC()->o_tile;
20878 }
20879 else if(GuyH::getNPC()->drownclk == 0 && value != 0) GuyH::getNPC()->old_cset = GuyH::getNPC()->cs;
20880 GuyH::getNPC()->drownclk = vbound(value/10000,0,70);
20881 }
20882 break;
20883 case NPCDROWNCMB:
20884 if(GuyH::loadNPC(ri->guyref, "npc->DrowningCombo") == SH::_NoError)
20885 {
20886 GuyH::getNPC()->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
20887 }
20888 case NPCFAKEZ:
20889 {
20890 if(GuyH::loadNPC(ri->guyref, "npc->FakeZ") == SH::_NoError)
20891 {
20892 if(!never_in_air(GuyH::getNPC()->id))
20893 {
20894 if(value < 0)
20895 GuyH::getNPC()->fakez = 0_zf;
20896 else
20897 GuyH::getNPC()->fakez = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
20898
20899 if(GuyH::hasHero())
20900 Hero.setFakeZfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
20901 }
20902 }
20903 }
20904 break;
20905 case NPCMOVEFLAGS:
20906 {
20907 if(GuyH::loadNPC(ri->guyref, "npc->MoveFlags[]") == SH::_NoError)
20908 {
20909 int32_t indx = ri->d[rINDEX]/10000;
20910 if(BC::checkBounds(indx, 0, 15, "npc->MoveFlags[]") == SH::_NoError)
20911 {
20912 //All bits, in order, of a single byte; just use bitwise
20913 int32_t bit = 1<<indx;
20914 if(value)
20915 GuyH::getNPC()->moveflags |= bit;
20916 else
20917 GuyH::getNPC()->moveflags &= ~bit;
20918 }
20919 }
20920 break;
20921 }
20922
20923 case NPCGLOWRAD:
20924 if(GuyH::loadNPC(ri->guyref, "npc->LightRadius") == SH::_NoError)
20925 {
20926 GuyH::getNPC()->glowRad = vbound(value/10000,0,255);
20927 }
20928 break;
20929 case NPCGLOWSHP:
20930 if(GuyH::loadNPC(ri->guyref, "npc->LightShape") == SH::_NoError)
20931 {
20932 GuyH::getNPC()->glowShape = vbound(value/10000,0,255);
20933 }
20934 break;
20935
20936 case NPCSHADOWSPR:
20937 if(GuyH::loadNPC(ri->guyref, "npc->ShadowSprite") == SH::_NoError)
20938 {
20939 GuyH::getNPC()->spr_shadow = vbound(value/10000,0,255);
20940 }
20941 break;
20942 case NPCSPAWNSPR:
20943 if(GuyH::loadNPC(ri->guyref, "npc->SpawnSprite") == SH::_NoError)
20944 {
20945 GuyH::getNPC()->spr_spawn = vbound(value/10000,0,255);
20946 }
20947 break;
20948 case NPCDEATHSPR:
20949 if(GuyH::loadNPC(ri->guyref, "npc->DeathSprite") == SH::_NoError)
20950 {
20951 GuyH::getNPC()->spr_death = vbound(value/10000,0,255);
20952 }
20953 break;
20954 case NPCSWHOOKED:
20955 break; //read-only
20956 case NPCCANFLICKER:
20957 if(GuyH::loadNPC(ri->guyref, "npc->InvFlicker") == SH::_NoError)
20958 {
20959 GuyH::getNPC()->setCanFlicker(value != 0);
20960 }
20961 break;
20962
20963
20964 ///----------------------------------------------------------------------------------------------------//
20965 //Game Information
20966
20967 case GAMEDEATHS:
20968 game->set_deaths(value/10000);
20969 break;
20970
20971 case GAMECHEAT:
20972 cheat=vbound(value/10000,0,4);
20973 if(maxcheat < cheat) maxcheat = cheat;
20974 if(cheat) game->did_cheat(true);
20975 break;
20976
20977 case GAMEMAXCHEAT:
20978 maxcheat=vbound(value/10000,0,4);
20979 game->set_cheat(maxcheat);
20980 if(cheat > maxcheat) cheat = maxcheat;
20981 break;
20982
20983 case GAMETIME:
20984 1 game->set_time(value);
20985 1 break; // Can't multiply by 10000 or the maximum result is too big
20986
20987 case ACTIVESSSPEED:
20988 Hero.subscr_speed = vbound((value/10000),1,85);
20989 break; // Can't multiply by 10000 or the maximum result is too big
20990
20991 case GAMETIMEVALID:
20992 game->set_timevalid((value/10000)?1:0);
20993 break;
20994
20995 case GAMEHASPLAYED:
20996 game->set_hasplayed((value/10000)?1:0);
20997 break;
20998
20999 case TYPINGMODE:
21000 FFCore.kb_typing_mode = ((value/10000)?true:false);
21001 break;
21002
21003 case SKIPCREDITS:
21004 FFCore.skip_ending_credits = ((value/10000)?true:false);
21005 break;
21006
21007 case SKIPF6:
21008 set_qr(qr_NOCONTINUE,((value/10000)?1:0));
21009 break;
21010
21011
21012
21013 case GAMEGUYCOUNT:
21014 {
21015 26 int32_t mi2 = (currmap*MAPSCRSNORMAL)+(ri->d[rINDEX]/10000);
21016 26 game->guys[mi2]=value/10000;
21017 }
21018 26 break;
21019
21020 case GAMECONTSCR:
21021 88964 game->set_continue_scrn(value/10000);
21022 88964 break;
21023
21024 case GAMECONTDMAP:
21025 88964 game->set_continue_dmap(value/10000);
21026 88964 break;
21027
21028 case GAMEENTRSCR:
21029 88970 lastentrance=value/10000;
21030 88970 break;
21031
21032 case GAMEENTRDMAP:
21033 88970 lastentrance_dmap=value/10000;
21034 88970 break;
21035
21036 case GAMECOUNTERD:
21037 2705905 game->set_counter(value/10000, (ri->d[rINDEX])/10000);
21038 2705905 break;
21039
21040 case GAMEMCOUNTERD:
21041 551 game->set_maxcounter(value/10000, (ri->d[rINDEX])/10000);
21042 551 break;
21043
21044 case GAMEDCOUNTERD:
21045 8 game->set_dcounter(value/10000, (ri->d[rINDEX])/10000);
21046 8 break;
21047
21048 case GAMEGENERICD:
21049 {
21050 auto indx = ri->d[rINDEX] / 10000;
21051 auto val = value/10000;
21052 switch(indx)
21053 {
21054 case genCONTHP:
21055 {
21056 if(!get_qr(qr_SCRIPT_CONTHP_IS_HEARTS) || game->get_cont_percent())
21057 game->set_generic(val, indx);
21058 else
21059 game->set_generic(val*game->get_hp_per_heart(), indx);
21060 break;
21061 }
21062 default:
21063 game->set_generic(val, indx);
21064 break;
21065 }
21066 break;
21067 }
21068 case GAMEMISC:
21069 {
21070 int32_t indx = ri->d[rINDEX]/10000;
21071 if ( indx < 0 || indx > 31 )
21072 {
21073 Z_scripterrlog("Invalid index used to access Game->Misc: %d\n", indx);
21074 }
21075 else
21076 {
21077 QMisc.questmisc[indx] = (value/((get_qr(qr_OLDQUESTMISC)) ? 10000 : 1));
21078 }
21079 break;
21080 }
21081 case GAMEITEMSD:
21082 game->set_item((ri->d[rINDEX])/10000,(value!=0));
21083 break;
21084
21085 case DISABLEDITEM:
21086 {
21087 int id = (ri->d[rINDEX])/10000;
21088 if(unsigned(id) >= MAXITEMS)
21089 break;
21090 game->items_off[id]=value/10000;
21091 removeFromItemCache(itemsbuf[id].family);
21092 break;
21093 }
21094
21095 case GAMESUSPEND:
21096 {
21097 131 int32_t inx = (ri->d[rINDEX])/10000;
21098
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if ( (unsigned) inx > (susptLAST-1) )
21099 {
21100 Z_scripterrlog("Invalid array index [%d] passed to Gme->Suspend[]\n");
21101 }
21102 131 FFCore.system_suspend[inx]= ( (value) ? 1 : 0 );
21103 131 break;
21104 }
21105
21106 case GAMELITEMSD:
21107 64 game->lvlitems[(ri->d[rINDEX])/10000]=value/10000;
21108 64 break;
21109 case GAMELSWITCH:
21110 {
21111 int32_t ind = (ri->d[rINDEX])/10000;
21112 if(unsigned(ind) < MAXLEVELS)
21113 game->lvlswitches[ind]=value;
21114 break;
21115 }
21116 case GAMEGSWITCH:
21117 {
21118 int32_t ind = (ri->d[rINDEX])/10000;
21119 if(unsigned(ind) < NUM_GSWITCHES)
21120 game->gswitch_timers[ind]=value/10000;
21121 break;
21122 }
21123 case GAMEBOTTLEST:
21124 game->set_bottle_slot((ri->d[rINDEX])/10000,value/10000);
21125 break;
21126
21127 case TANGOARR:
21128 {
21129 int32_t inx = (ri->d[rINDEX])/10000;
21130 if ( ((unsigned)inx) > 255 )
21131 {
21132 Z_scripterrlog("Invalid index %d supplied to Game->Tango[].\n", inx);
21133 break;
21134 }
21135 else
21136 {
21137 FFCore.TangoArray[inx]=value/10000;
21138 break;
21139 }
21140 }
21141
21142 case GHOSTARR:
21143 {
21144 int32_t inx = (ri->d[rINDEX])/10000;
21145 if ( ((unsigned)inx) > 255 )
21146 {
21147 Z_scripterrlog("Invalid index %d supplied to Game->Ghost[].\n", inx);
21148 break;
21149 }
21150 else
21151 {
21152
21153 FFCore.GhostArray[inx]=value/10000;;
21154 break;
21155 }
21156 }
21157 case STDARR:
21158 {
21159 int32_t inx = (ri->d[rINDEX])/10000;
21160 if ( ((unsigned)inx) > 255 )
21161 {
21162 Z_scripterrlog("Invalid index %d supplied to Game->STD[].\n", inx);
21163 break;
21164 }
21165 else
21166 {
21167 FFCore.StdArray[inx]=value/10000;
21168 break;
21169 }
21170 }
21171
21172 case GAMEMISCSPR:
21173 {
21174 int32_t inx = (ri->d[rINDEX])/10000;
21175 if ( ((unsigned)inx) > sprMAX )
21176 {
21177 Z_scripterrlog("Invalid index %d supplied to Game->MiscSprites[].\n", inx);
21178 }
21179 else
21180 {
21181 QMisc.sprites[inx] = vbound(value/10000, 0, 255);
21182 }
21183 break;
21184 }
21185 case GAMEMISCSFX:
21186 {
21187 int32_t inx = (ri->d[rINDEX])/10000;
21188 if ( ((unsigned)inx) > sfxMAX )
21189 {
21190 Z_scripterrlog("Invalid index %d supplied to Game->MiscSFX[].\n", inx);
21191 }
21192 else
21193 {
21194 QMisc.miscsfx[inx] = vbound(value/10000, 0, 255);
21195 }
21196 break;
21197 }
21198 case GAMEOVERRIDEITEMS:
21199 {
21200 int32_t ind = (ri->d[rINDEX])/10000;
21201 if(unsigned(ind) >= itype_max)
21202 {
21203 Z_scripterrlog("Invalid index %d supplied to Game->OverrideItems[].\n", ind);
21204 }
21205 else
21206 {
21207 auto val = value/10000;
21208 game->OverrideItems[ind] = (val < -1 || val >= MAXITEMS) ? -2 : val;
21209 }
21210 break;
21211 }
21212 case GAMEEVENTDATA:
21213 {
21214 int32_t inx = (ri->d[rINDEX])/10000;
21215 if ( ((unsigned)inx) < FFCore.eventData.size() )
21216 {
21217 FFCore.eventData[inx] = value;
21218 }
21219 break;
21220 }
21221 case GAMEMOUSECURSOR:
21222 {
21223 int v = value/10000;
21224 if(v < 0 || v >= ZCM_MAX)
21225 break;
21226 game_mouse_index = v;
21227 game_mouse();
21228 break;
21229 }
21230 case GAMETRIGGROUPS:
21231 break; //read-only
21232
21233 case GAMELKEYSD:
21234 3 game->lvlkeys[(ri->d[rINDEX])/10000]=value/10000;
21235 3 break;
21236
21237 case GAMEGRAVITY:
21238 {
21239 int32_t indx = ri->d[rINDEX]/10000;
21240 if(indx < 0 || indx > 2)
21241 {
21242 Z_scripterrlog("Invalid index used to access Game->Gravity[]: %d\n", indx);
21243 }
21244 else
21245 {
21246 switch(indx)
21247 {
21248 case 0: //Gravity Strength
21249 zinit.gravity = value;
21250 break;
21251 case 1: //Terminal Velocity
21252 zinit.terminalv = value / 100;
21253 break;
21254 case 2: //Sprite Layer Threshold
21255 zinit.jump_hero_layer_threshold = value / 10000;
21256 break;
21257 }
21258 }
21259 break;
21260 }
21261
21262 case SCREENSTATED:
21263 {
21264 394 int32_t mi2 = (currmap*MAPSCRSNORMAL)+currscr;
21265
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 4 times.
394 (value)?setmapflag(mi2, 1<<((ri->d[rINDEX])/10000)) : unsetmapflag(mi2, 1 << ((ri->d[rINDEX]) / 10000));
21266 }
21267 394 break;
21268 case SCREENEXSTATED:
21269 {
21270 int32_t mi2 = (currmap*MAPSCRSNORMAL)+currscr;
21271 (value)?setxmapflag(mi2, 1<<((ri->d[rINDEX])/10000)) : unsetxmapflag(mi2, 1 << ((ri->d[rINDEX]) / 10000));
21272 }
21273 break;
21274 case SCREENLENSSHOWS:
21275 {
21276 int ind = ri->d[rINDEX]/10000;
21277 if(ind < 0 || ind > 6)
21278 Z_scripterrlog("Bad index Screen->LensShows[%d]\n",ind);
21279 else
21280 {
21281 SETFLAG(tmpscr->lens_show, 1<<ind, value);
21282 if(value) tmpscr->lens_hide &= ~(1<<ind);
21283 }
21284 break;
21285 }
21286 case SCREENLENSHIDES:
21287 {
21288 int ind = ri->d[rINDEX]/10000;
21289 if(ind < 0 || ind > 6)
21290 Z_scripterrlog("Bad index Screen->LensHides[%d]\n",ind);
21291 else
21292 {
21293 SETFLAG(tmpscr->lens_hide, 1<<ind, value);
21294 if(value) tmpscr->lens_show &= ~(1<<ind);
21295 }
21296 break;
21297 }
21298 case SCREENSCRDATASIZE:
21299 {
21300 auto mi = get_total_mi();
21301 if(mi < 0) break;
21302 game->scriptDataResize(mi, value/10000);
21303 break;
21304 }
21305 case SCREENSCRDATA:
21306 {
21307 auto mi = get_total_mi();
21308 if(mi < 0) break;
21309 size_t indx = ri->d[rINDEX]/10000;
21310 if(indx >= game->scriptDataSize(mi))
21311 {
21312 Z_scripterrlog("Invalid index passed to Screen->Data[]: %d\n", indx);
21313 break;
21314 }
21315 game->screen_data[mi][indx] = value;
21316 break;
21317 }
21318
21319 case SCREENSTATEDD:
21320 {
21321 649 int32_t mi2 = ri->d[rINDEX]/10000;
21322 649 mi2 -= 8*(mi2/MAPSCRS);
21323
21324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 649 times.
649 if(BC::checkMapID(mi2>>7, "Game->SetScreenState") == SH::_NoError)
21325
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 455 times.
649 (value)?setmapflag(mi2, 1<<(ri->d[rINDEX2]/10000)) : unsetmapflag(mi2, 1 << (ri->d[rINDEX2] / 10000), true);
21326 }
21327 649 break;
21328
21329 case GAMEGUYCOUNTD:
21330 game->guys[(currmap*MAPSCRSNORMAL)+(ri->d[rINDEX]/10000)] = value / 10000;
21331 break;
21332
21333 case GAMECLICKFREEZE:
21334 disableClickToFreeze=value==0;
21335 break;
21336
21337
21338 case NOACTIVESUBSC:
21339 Hero.stopSubscreenFalling((value/10000)?1:0);
21340 break;
21341
21342 ///----------------------------------------------------------------------------------------------------//
21343 //BottleTypes
21344 case BOTTLECOUNTER:
21345 {
21346 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Counter[]"))
21347 {
21348 int32_t indx = ri->d[rINDEX]/10000;
21349 int32_t ctr = vbound(value/10000, -1, MAX_COUNTERS-1);
21350 if(unsigned(indx) > 2)
21351 {
21352 Z_scripterrlog("Invalid index %d supplied to bottledata->Counter[].\n", indx);
21353 break;
21354 }
21355 ptr->counter[indx] = ctr;
21356 }
21357 }
21358 break;
21359
21360 case BOTTLEAMOUNT:
21361 {
21362 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Amount[]"))
21363 {
21364 int32_t indx = ri->d[rINDEX]/10000;
21365 int32_t amnt = vbound(value/10000, 0, 65535);
21366 if(unsigned(indx) > 2)
21367 {
21368 Z_scripterrlog("Invalid index %d supplied to bottledata->Amount[].\n", indx);
21369 break;
21370 }
21371 ptr->amount[indx] = amnt;
21372 }
21373 }
21374 break;
21375
21376 case BOTTLEPERCENT:
21377 {
21378 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "IsPercent[]"))
21379 {
21380 int32_t indx = ri->d[rINDEX]/10000;
21381 if(unsigned(indx) > 2)
21382 {
21383 Z_scripterrlog("Invalid index %d supplied to bottledata->IsPercent[].\n", indx);
21384 break;
21385 }
21386 SETFLAG(ptr->flags, 1<<indx, value);
21387 }
21388 }
21389 break;
21390
21391 case BOTTLEFLAGS:
21392 {
21393 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Flags[]"))
21394 {
21395 int32_t indx = ri->d[rINDEX]/10000;
21396 if(unsigned(indx) > 3)
21397 {
21398 Z_scripterrlog("Invalid index %d supplied to bottledata->Flags[].\n", indx);
21399 break;
21400 }
21401 int32_t flag = 0;
21402 switch(indx)
21403 {
21404 case 0: flag = BTFLAG_AUTOONDEATH; break;
21405 case 1: flag = BTFLAG_ALLOWIFFULL; break;
21406 case 2: flag = BTFLAG_CURESWJINX; break;
21407 case 3: flag = BTFLAG_CUREITJINX; break;
21408 }
21409 SETFLAG(ptr->flags, flag, value);
21410 }
21411 }
21412 break;
21413
21414 case BOTTLENEXT:
21415 {
21416 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "NextType"))
21417 {
21418 ptr->next_type = vbound(value/10000, 0, 64);
21419 }
21420 }
21421 break;
21422 ///----------------------------------------------------------------------------------------------------//
21423 //BottleShops
21424 case BSHOPFILL:
21425 {
21426 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Fill[]"))
21427 {
21428 int32_t indx = ri->d[rINDEX]/10000;
21429 if(unsigned(indx) > 2)
21430 {
21431 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Fill[].\n", indx);
21432 break;
21433 }
21434 ptr->fill[indx] = vbound(value/10000, 0, 64);
21435 }
21436 }
21437 break;
21438
21439 case BSHOPCOMBO:
21440 {
21441 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Combo[]"))
21442 {
21443 int32_t indx = ri->d[rINDEX]/10000;
21444 if(unsigned(indx) > 2)
21445 {
21446 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Combo[].\n", indx);
21447 break;
21448 }
21449 ptr->comb[indx] = vbound(value/10000, 0, MAXCOMBOS-1);
21450 }
21451 }
21452 break;
21453
21454 case BSHOPCSET:
21455 {
21456 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "CSet[]"))
21457 {
21458 int32_t indx = ri->d[rINDEX]/10000;
21459 if(unsigned(indx) > 2)
21460 {
21461 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->CSet[].\n", indx);
21462 break;
21463 }
21464 ptr->cset[indx] = vbound(value/10000, 0, 11);
21465 }
21466 }
21467 break;
21468
21469 case BSHOPPRICE:
21470 {
21471 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Price[]"))
21472 {
21473 int32_t indx = ri->d[rINDEX]/10000;
21474 if(unsigned(indx) > 2)
21475 {
21476 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Price[].\n", indx);
21477 break;
21478 }
21479 ptr->price[indx] = vbound(value/10000, 0, 65535);
21480 }
21481 }
21482 break;
21483
21484 case BSHOPSTR:
21485 {
21486 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "InfoString[]"))
21487 {
21488 int32_t indx = ri->d[rINDEX]/10000;
21489 if(unsigned(indx) > 2)
21490 {
21491 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->InfoString[].\n", indx);
21492 break;
21493 }
21494 ptr->str[indx] = vbound(value/10000, 0, 65535);
21495 }
21496 }
21497 break;
21498 ///----------------------------------------------------------------------------------------------------//
21499 //DMap Information
21500
21501 #define SET_DMAP_VAR(member, str) \
21502 { \
21503 int32_t ID = ri->d[rINDEX] / 10000; \
21504 if(BC::checkDMapID(ID, str) == SH::_NoError) \
21505 DMaps[ID].member = value / 10000; \
21506 }
21507
21508 case DMAPFLAGSD:
21509 SET_DMAP_VAR(flags, "Game->DMapFlags") break;
21510
21511 case DMAPLEVELD:
21512 SET_DMAP_VAR(level, "Game->DMapLevel") break;
21513
21514 case DMAPCOMPASSD:
21515 SET_DMAP_VAR(compass, "Game->DMapCompass") break;
21516
21517 case DMAPCONTINUED:
21518 SET_DMAP_VAR(cont, "Game->DMapContinue") break;
21519
21520 case DMAPLEVELPAL:
21521 {
21522 377 int32_t ID = ri->d[rINDEX] / 10000;
21523 377 int32_t pal = value/10000;
21524 377 pal = vbound(pal, 0, 0x1FF);
21525
21526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if(BC::checkDMapID(ID, "Game->DMapPalette") == SH::_NoError)
21527 377 DMaps[ID].color = pal;
21528
21529
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 10 times.
377 if(ID == currdmap)
21530 {
21531 10 loadlvlpal(DMaps[ID].color);
21532 10 currcset = DMaps[ID].color;
21533 10 }
21534 377 break;
21535 }
21536
21537 case DMAPMIDID:
21538 {
21539 int32_t ID = ri->d[rINDEX] / 10000;
21540
21541 if(BC::checkDMapID(ID, "Game->DMapMIDI") == SH::_NoError)
21542 {
21543 // Based on play_DmapMusic
21544 switch(value / 10000)
21545 {
21546 case -6:
21547 DMaps[ID].midi = 2;
21548 break; // Dungeon
21549
21550 case -3:
21551 DMaps[ID].midi = 3;
21552 break; // Level 9
21553
21554 case -2:
21555 DMaps[ID].midi = 1;
21556 break; // Overworld
21557
21558 case 0:
21559 DMaps[ID].midi = 0;
21560 break; // None
21561
21562 default:
21563 DMaps[ID].midi = value / 10000 + 3;
21564 }
21565 }
21566
21567 break;
21568 }
21569
21570 ///----------------------------------------------------------------------------------------------------//
21571 //Screen->ComboX
21572 case COMBODD:
21573 {
21574 120341 int32_t pos = (ri->d[rINDEX])/10000;
21575 120341 int32_t val = (value/10000);
21576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120341 times.
120341 if ( ((unsigned) pos) > 175 )
21577 {
21578 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboD[]\n", pos);
21579 }
21580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120341 times.
120341 else if ( ((unsigned) val) >= MAXCOMBOS )
21581 {
21582 Z_scripterrlog("Invalid combo ID %d used to write to Screen->ComboD[]\n", val);
21583 }
21584 else
21585 {
21586 120341 screen_combo_modify_preroutine(tmpscr,pos);
21587 120341 tmpscr->data[pos]=(val);
21588 120341 screen_combo_modify_postroutine(tmpscr,pos);
21589 }
21590 }
21591 120341 break;
21592
21593 case COMBOCD:
21594 {
21595 6481 int32_t pos = (ri->d[rINDEX])/10000;
21596 6481 int32_t val = (value/10000); //cset
21597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6481 times.
6481 if ( ((unsigned) pos) > 175 )
21598 {
21599 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboC[]\n", pos);
21600 }
21601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6481 times.
6481 else if ( ((unsigned) val) >= 15 )
21602 {
21603 Z_scripterrlog("Invalid CSet ID %d used to write to Screen->ComboC[]\n", val);
21604 }
21605 else
21606 {
21607 6481 screen_combo_modify_preroutine(tmpscr,pos);
21608 6481 tmpscr->cset[pos]=(val)&15;
21609 6481 screen_combo_modify_postroutine(tmpscr,pos);
21610 }
21611 }
21612 6481 break;
21613
21614 case COMBOFD:
21615 {
21616 int32_t pos = (ri->d[rINDEX])/10000;
21617 int32_t val = (value/10000); //flag
21618 if ( ((unsigned) pos) > 175 )
21619 {
21620 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboF[]\n", pos);
21621 }
21622 else if ( ((unsigned) val) >= 256 )
21623 {
21624 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboF[]\n", val);
21625 }
21626
21627 else
21628 tmpscr->sflag[pos]=(val);
21629 }
21630 break;
21631
21632 case COMBOTD:
21633 {
21634 3560 int32_t pos = (ri->d[rINDEX])/10000;
21635 3560 int32_t val = (value/10000); //type
21636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3560 times.
3560 if ( ((unsigned) pos) > 175 )
21637 {
21638 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboT[]\n", pos);
21639 }
21640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3560 times.
3560 else if ( ((unsigned) val) >= 256 )
21641 {
21642 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboT[]\n", val);
21643 }
21644 else
21645 {
21646 3560 auto cid = tmpscr->data[pos];
21647 3560 screen_combo_modify_pre(cid);
21648 3560 combobuf[cid].type=val;
21649 3560 screen_combo_modify_post(cid);
21650 }
21651 }
21652 3560 break;
21653
21654 case COMBOID:
21655 {
21656 int32_t pos = (ri->d[rINDEX])/10000;
21657 int32_t val = (value/10000); //iflag
21658 if ( ((unsigned) pos) > 175 )
21659 {
21660 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboI[]\n", pos);
21661 }
21662 else if ( ((unsigned) val) >= 256 )
21663 {
21664 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboI[]\n", val);
21665 }
21666
21667 else
21668 combobuf[tmpscr->data[pos]].flag=val;
21669 }
21670 break;
21671
21672 case COMBOSD:
21673 {
21674 81346 int32_t pos = (ri->d[rINDEX])/10000;
21675 81346 int32_t val = (value/10000); //iflag
21676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81346 times.
81346 if ( ((unsigned) pos) > 175 )
21677 {
21678 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboS[]\n", pos);
21679 }
21680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81346 times.
81346 else if ( ((unsigned) val) >= 16 )//solidity 1, 2, 4, 8 max 15
21681 {
21682 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboS[]\n", val);
21683 }
21684 else
21685 {
21686 81346 combobuf[tmpscr->data[pos]].walk &= ~0x0F;
21687 81346 combobuf[tmpscr->data[pos]].walk |= (val)&0x0F;
21688 }
21689 }
21690 81346 break;
21691
21692 case COMBOED:
21693 {
21694 int32_t pos = (ri->d[rINDEX])/10000;
21695 int32_t val = (value/10000); //iflag
21696 if ( ((unsigned) pos) > 175 )
21697 {
21698 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboE[]\n", pos);
21699 }
21700 else if ( ((unsigned) val) >= 16 )//solidity 1, 2, 4, 8 max 15
21701 {
21702 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboE[]\n", val);
21703 }
21704 else
21705 {
21706 combobuf[tmpscr->data[pos]].walk &= ~0xF0;
21707 combobuf[tmpscr->data[pos]].walk |= ((val)&0x0F)<<4;
21708 }
21709 }
21710 break;
21711
21712 ///----------------------------------------------------------------------------------------------------//
21713 //Game->SetComboX
21714 case COMBODDM:
21715 {
21716 5356632 int32_t pos = (ri->d[rINDEX])/10000;
21717 5356632 int32_t sc = (ri->d[rEXP1]/10000);
21718 5356632 int32_t m = (ri->d[rINDEX2]/10000)-1;
21719
1/2
✓ Branch 0 taken 5356632 times.
✗ Branch 1 not taken.
5356632 int32_t scr = zc_max(m*MAPSCRS+sc,0);
21720 5356632 int32_t layr = whichlayer(scr);
21721
21722 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)) break;
21723
21724
2/4
✓ Branch 0 taken 5356632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5356632 times.
5356632 if(pos < 0 || pos >= 176)
21725 {
21726 Z_scripterrlog("Invalid combo position (%d) passed to SetComboData", pos);
21727 break;
21728 }
21729
1/2
✓ Branch 0 taken 5356632 times.
✗ Branch 1 not taken.
5356632 if(scr < 0)
21730 {
21731 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboData", scr);
21732 break;
21733 }
21734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5356632 times.
5356632 if(sc >= MAPSCRS)
21735 {
21736 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboData", sc);
21737 break;
21738 }
21739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5356632 times.
5356632 if(unsigned(m) >= map_count)
21740 {
21741 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboData", m);
21742 break;
21743 }
21744 5356632 int32_t combo = vbound(value/10000,0,MAXCOMBOS);
21745
2/2
✓ Branch 0 taken 5356419 times.
✓ Branch 1 taken 213 times.
5356632 if(scr==(currmap*MAPSCRS+currscr))
21746 {
21747 213 screen_combo_modify_preroutine(tmpscr,pos);
21748
21749 213 }
21750
21751 5356632 TheMaps[scr].data[pos]=combo;
21752
21753
2/2
✓ Branch 0 taken 5356419 times.
✓ Branch 1 taken 213 times.
5356632 if(scr==(currmap*MAPSCRS+currscr))
21754 {
21755 213 tmpscr->data[pos] = combo;
21756 213 screen_combo_modify_postroutine(tmpscr,pos);
21757 //Start the script for the new combo
21758 213 int index = get_combopos_ref(pos, 0);
21759 213 FFCore.reset_script_engine_data(ScriptType::Combo, index);
21760 //Not ure if combodata arrays clean themselves up, or leak. -Z
21761 //Not sure if this could result in stack corruption.
21762 213 }
21763
21764
2/2
✓ Branch 0 taken 5350083 times.
✓ Branch 1 taken 6549 times.
5356632 if(layr>-1)
21765 {
21766 6549 tmpscr2[layr].data[pos]=combo;
21767 6549 int index = get_combopos_ref(pos, layr + 1);
21768 6549 FFCore.reset_script_engine_data(ScriptType::Combo, index);
21769 6549 }
21770 }
21771 5356632 break;
21772
21773 case COMBOCDM:
21774 {
21775 5344380 int32_t pos = (ri->d[rINDEX])/10000;
21776 5344380 int32_t sc = (ri->d[rEXP1]/10000);
21777 5344380 int32_t m = (ri->d[rINDEX2]/10000)-1;
21778
1/2
✓ Branch 0 taken 5344380 times.
✗ Branch 1 not taken.
5344380 int32_t scr = zc_max(m*MAPSCRS+sc,0);
21779
21780 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)) break;
21781
21782
2/4
✓ Branch 0 taken 5344380 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5344380 times.
5344380 if(pos < 0 || pos >= 176)
21783 {
21784 Z_scripterrlog("Invalid combo position (%d) passed to SetComboCSet", pos);
21785 break;
21786 }
21787
1/2
✓ Branch 0 taken 5344380 times.
✗ Branch 1 not taken.
5344380 if(scr < 0)
21788 {
21789 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboCSet", scr);
21790 break;
21791 }
21792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5344380 times.
5344380 if(sc >= MAPSCRS)
21793 {
21794 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboCSet", sc);
21795 break;
21796 }
21797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5344380 times.
5344380 if(unsigned(m) >= map_count)
21798 {
21799 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboCSet", m);
21800 break;
21801 }
21802
21803 5344380 TheMaps[scr].cset[pos]=(value/10000)&15;
21804
21805
2/2
✓ Branch 0 taken 5344340 times.
✓ Branch 1 taken 40 times.
5344380 if(scr==(currmap*MAPSCRS+currscr))
21806 40 tmpscr->cset[pos] = value/10000;
21807
21808 5344380 int32_t layr = whichlayer(scr);
21809
21810
2/2
✓ Branch 0 taken 3042 times.
✓ Branch 1 taken 5341338 times.
5344380 if(layr>-1)
21811 3042 tmpscr2[layr].cset[pos]=(value/10000)&15;
21812 }
21813 5344380 break;
21814
21815 case COMBOFDM:
21816 {
21817 32221 int32_t pos = (ri->d[rINDEX])/10000;
21818 32221 int32_t sc = (ri->d[rEXP1]/10000);
21819 32221 int32_t m = (ri->d[rINDEX2]/10000)-1;
21820
1/2
✓ Branch 0 taken 32221 times.
✗ Branch 1 not taken.
32221 int32_t scr = zc_max(m*MAPSCRS+sc,0);
21821
21822 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)) break;
21823
21824
2/4
✓ Branch 0 taken 32221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32221 times.
32221 if(pos < 0 || pos >= 176)
21825 {
21826 Z_scripterrlog("Invalid combo position (%d) passed to SetComboFlag", pos);
21827 break;
21828 }
21829
1/2
✓ Branch 0 taken 32221 times.
✗ Branch 1 not taken.
32221 if(scr < 0)
21830 {
21831 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboFlag", scr);
21832 break;
21833 }
21834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32221 times.
32221 if(sc >= MAPSCRS)
21835 {
21836 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboFlag", sc);
21837 break;
21838 }
21839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32221 times.
32221 if(unsigned(m) >= map_count)
21840 {
21841 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboFlag", m);
21842 break;
21843 }
21844
21845 32221 TheMaps[scr].sflag[pos]=value/10000;
21846
21847
2/2
✓ Branch 0 taken 32153 times.
✓ Branch 1 taken 68 times.
32221 if(scr==(currmap*MAPSCRS+currscr))
21848 68 tmpscr->sflag[pos] = value/10000;
21849
21850 32221 int32_t layr = whichlayer(scr);
21851
21852
2/2
✓ Branch 0 taken 32210 times.
✓ Branch 1 taken 11 times.
32221 if(layr>-1)
21853 11 tmpscr2[layr].sflag[pos]=value/10000;
21854 }
21855 32221 break;
21856
21857 case COMBOTDM:
21858 {
21859 760 int32_t pos = (ri->d[rINDEX])/10000;
21860 760 int32_t sc = (ri->d[rEXP1]/10000);
21861 760 int32_t m = (ri->d[rINDEX2]/10000)-1;
21862
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 int32_t scr = zc_max(m*MAPSCRS+sc,0);
21863
21864 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count))
21865 // break;
21866
21867
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(pos < 0 || pos >= 176)
21868 {
21869 Z_scripterrlog("Invalid combo position (%d) passed to SetComboType", pos);
21870 break;
21871 }
21872
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(scr < 0)
21873 {
21874 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboType", scr);
21875 break;
21876 }
21877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(sc >= MAPSCRS)
21878 {
21879 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboType", sc);
21880 break;
21881 }
21882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(unsigned(m) >= map_count)
21883 {
21884 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboType", m);
21885 break;
21886 }
21887
21888 760 int32_t cdata = TheMaps[scr].data[pos];
21889 760 screen_combo_modify_pre(cdata);
21890 760 combobuf[cdata].type=value/10000;
21891 760 screen_combo_modify_post(cdata);
21892 }
21893 760 break;
21894
21895 case COMBOIDM:
21896 {
21897 int32_t pos = (ri->d[rINDEX])/10000;
21898 int32_t sc = (ri->d[rEXP1]/10000);
21899 int32_t m = (ri->d[rINDEX2]/10000)-1;
21900 int32_t scr = zc_max(m*MAPSCRS+sc,0);
21901
21902 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count))
21903 // break;
21904
21905 if(pos < 0 || pos >= 176)
21906 {
21907 Z_scripterrlog("Invalid combo position (%d) passed to GetComboInherentFlag", pos);
21908 break;
21909 }
21910 if(scr < 0)
21911 {
21912 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", scr);
21913 break;
21914 }
21915 if(sc >= MAPSCRS)
21916 {
21917 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", sc);
21918 break;
21919 }
21920 if(unsigned(m) >= map_count)
21921 {
21922 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboInherentFlag", m);
21923 break;
21924 }
21925
21926 combobuf[TheMaps[scr].data[pos]].flag=value/10000;
21927 }
21928 break;
21929
21930 case COMBOSDM:
21931 {
21932 //This is how it was in 2.50.1-2
21933 int32_t pos = (ri->d[rINDEX])/10000;
21934 int32_t scr = (ri->d[rINDEX2]/10000)*MAPSCRS+(ri->d[rEXP1]/10000);
21935 //This (below) us the precise code from 2.50.1 (?)
21936 //int32_t scr = zc_max((ri->d[rINDEX2]/10000)*MAPSCRS+(ri->d[rEXP1]/10000),0); //Not below 0.
21937
21938 //if(pos < 0 || pos >= 176 || scr < 0) break;
21939 if(pos < 0 || pos >= 176)
21940 {
21941 Z_scripterrlog("Invalid combo position (%d) passed to GetSolid", pos);
21942 break;
21943 }
21944 if(scr < 0)
21945 {
21946 Z_scripterrlog("Invalid MapScreen ID (%d) passed to GetSolid", scr);
21947 break;
21948 }
21949 combobuf[TheMaps[scr].data[pos]].walk &= ~0x0F;
21950 combobuf[TheMaps[scr].data[pos]].walk |= (value/10000)&15;
21951 }
21952 break;
21953
21954 ///----------------------------------------------------------------------------------------------------//
21955 //Screen Variables
21956
21957 #define SET_SCREENDATA_VAR_INT32(member, str) \
21958 { \
21959 tmpscr->member = vbound((value / 10000),-214747,214747); \
21960 } \
21961
21962 #define SET_SCREENDATA_VAR_INT16(member, str) \
21963 { \
21964 tmpscr->member = vbound((value / 10000),0,32767); \
21965 } \
21966
21967 #define SET_SCREENDATA_VAR_BYTE(member, str) \
21968 { \
21969 tmpscr->member = vbound((value / 10000),0,255); \
21970 } \
21971
21972 #define SET_SCREENDATA_VAR_INDEX32(member, str, indexbound) \
21973 { \
21974 int32_t indx = ri->d[rINDEX] / 10000; \
21975 tmpscr->member[indx] = vbound((value / 10000),-214747,214747); \
21976 } \
21977
21978 #define SET_SCREENDATA_VAR_INDEX16(member, str, indexbound) \
21979 { \
21980 int32_t indx = ri->d[rINDEX] / 10000; \
21981 tmpscr->member[indx] = vbound((value / 10000),-32767,32767); \
21982 } \
21983
21984 #define SET_SCREENDATA_BYTE_INDEX(member, str, indexbound) \
21985 { \
21986 int32_t indx = ri->d[rINDEX] / 10000; \
21987 tmpscr->member[indx] = vbound((value / 10000),0,255); \
21988 }
21989 #define SET_SCREENDATA_LAYER_INDEX(member, str, indexbound) \
21990 { \
21991 int32_t indx = ri->d[rINDEX] / 10000; \
21992 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
21993 if(indx < 1 || indx > indexbound ) \
21994 { \
21995 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
21996 } \
21997 else tmpscr->member[indx-1] = vbound((value / 10000),0,255); \
21998 }
21999 ///max screen id is higher! vbound properly... -Z
22000 #define SET_SCREENDATA_LAYERSCREEN_INDEX(member, str, indexbound) \
22001 { \
22002 int32_t indx = ri->d[rINDEX] / 10000; \
22003 int32_t scrn_id = value/10000; \
22004 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
22005 if(indx < 1 || indx > indexbound ) \
22006 { \
22007 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22008 } \
22009 else if ( scrn_id > MAPSCRS ) \
22010 { \
22011 Z_scripterrlog("Script attempted to use a mapdata->LayerScreen[%d].\n",scrn_id); \
22012 Z_scripterrlog("Valid Screen values are (0) through (%d).\n",MAPSCRS); \
22013 } \
22014 else tmpscr->member[indx-1] = vbound((scrn_id),0,MAPSCRS); \
22015 }
22016
22017 #define SET_SCREENDATA_FLAG(member, str) \
22018 { \
22019 int32_t flag = (value/10000); \
22020 if ( flag != 0 ) \
22021 { \
22022 tmpscr->member|=flag; \
22023 } \
22024 else tmpscr->.member|= ~flag; \
22025 } \
22026
22027 #define SET_SCREENDATA_BOOL_INDEX(member, str, indexbound) \
22028 { \
22029 int32_t indx = ri->d[rINDEX] / 10000; \
22030 if(indx < 0 || indx > indexbound ) \
22031 { \
22032 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
22033 break; \
22034 } \
22035 tmpscr->member[indx] =( (value/10000) ? 1 : 0 ); \
22036 }
22037
22038 #define SET_FFC_BOOL_INDEX(member, str, indexbound) \
22039 { \
22040 int32_t indx = ri->d[rINDEX] / 10000; \
22041 if(indx < 0 || indx > indexbound ) \
22042 { \
22043 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
22044 break; \
22045 } \
22046 tmpscr->ffcs[indx].member =( (value/10000) ? 1 : 0 ); \
22047 }
22048
22049
22050 case SCREENDATAVALID: SET_SCREENDATA_VAR_BYTE(valid, "Valid"); break; //b
22051 case SCREENDATAGUY: SET_SCREENDATA_VAR_BYTE(guy, "Guy"); break; //b
22052 case SCREENDATASTRING: SET_SCREENDATA_VAR_INT32(str, "String"); break; //w
22053 case SCREENDATAROOM: SET_SCREENDATA_VAR_BYTE(room, "RoomType"); break; //b
22054 case SCREENDATAITEM:
22055 {
22056 auto v = vbound((value / 10000),-1,255);
22057 if(v > -1)
22058 tmpscr->item = v;
22059 tmpscr->hasitem = v > -1;
22060 break;
22061 }
22062 case SCREENDATAHASITEM: SET_SCREENDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
22063 case SCREENDATATILEWARPTYPE: SET_SCREENDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
22064 //case SCREENDATATILEWARPOVFLAGS: SET_SCREENDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
22065 case SCREENDATADOORCOMBOSET: SET_SCREENDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
22066 case SCREENDATAWARPRETX: SET_SCREENDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
22067 case SCREENDATAWARPRETY: SET_SCREENDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
22068 case SCREENDATAWARPRETURNC: SET_SCREENDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
22069 case SCREENDATASTAIRX: SET_SCREENDATA_VAR_BYTE(stairx, "StairsX"); break; //b
22070 case SCREENDATASTAIRY: SET_SCREENDATA_VAR_BYTE(stairy, "StairsY"); break; //b
22071 case SCREENDATAITEMX: SET_SCREENDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
22072 case SCREENDATAITEMY: SET_SCREENDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
22073 case SCREENDATACOLOUR: SET_SCREENDATA_VAR_INT32(color, "CSet"); break; //w
22074 case SCREENDATAENEMYFLAGS: SET_SCREENDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
22075 case SCREENDATADOOR: SET_SCREENDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
22076 case SCREENDATATILEWARPDMAP: SET_SCREENDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
22077 case SCREENDATATILEWARPSCREEN: SET_SCREENDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
22078 case SCREENDATAEXITDIR: SET_SCREENDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
22079 case SCREENDATAENEMY:
22080 {
22081 int32_t indx = ri->d[rINDEX] / 10000;
22082 int32_t enemyid = value/10000;
22083 if ( ((unsigned)enemyid) > MAXGUYS )
22084 {
22085 Z_scripterrlog("Invaid enemy ID (%d) passed to Screen->%s.", enemyid,"Enemy[]"); \
22086 break;
22087 }
22088 if(unsigned(indx) > 9)
22089 {
22090 Z_scripterrlog("Invalid index (%d) used for Screen->Enemy[]", indx);
22091 break;
22092 }
22093 tmpscr->enemy[indx] = enemyid;
22094 break;
22095 }
22096 //case SCREENDATAENEMY: SET_SCREENDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
22097 case SCREENDATAPATTERN: SET_SCREENDATA_VAR_BYTE(pattern, "Pattern"); break; //b
22098 case SCREENDATASIDEWARPTYPE: SET_SCREENDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
22099 //case SCREENDATASIDEWARPOVFLAGS: SET_SCREENDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
22100 case SCREENDATAWARPARRIVALX: SET_SCREENDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
22101 case SCREENDATAWARPARRIVALY: SET_SCREENDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
22102 case SCREENDATAPATH: SET_SCREENDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
22103 case SCREENDATASIDEWARPSC: SET_SCREENDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
22104 case SCREENDATASIDEWARPDMAP: SET_SCREENDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
22105 case SCREENDATASIDEWARPINDEX: SET_SCREENDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
22106 case SCREENDATAUNDERCOMBO: SET_SCREENDATA_VAR_INT32(undercombo, "Undercombo"); break; //w
22107 case SCREENDATAUNDERCSET: SET_SCREENDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
22108 case SCREENDATACATCHALL: SET_SCREENDATA_VAR_INT32(catchall, "Catchall"); break; //W
22109
22110 case SCREENDATACSENSITIVE: SET_SCREENDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
22111 case SCREENDATANORESET: SET_SCREENDATA_VAR_INT32(noreset, "NoReset"); break; //W
22112 case SCREENDATANOCARRY: SET_SCREENDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
22113 case SCREENDATALAYERMAP: SET_SCREENDATA_LAYER_INDEX(layermap, "LayerMap", 5); break; //B, 6 OF THESE
22114 case SCREENDATALAYERSCREEN: SET_SCREENDATA_LAYERSCREEN_INDEX(layerscreen, "LayerScreen", 5); break; //B, 6 OF THESE
22115 case SCREENDATALAYEROPACITY: SET_SCREENDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 5); break; //B, 6 OF THESE
22116 case SCREENDATALAYERINVIS:
22117 {
22118 int32_t indx = ri->d[rINDEX] / 10000;
22119 if(indx < 0 || indx > 6 )
22120 {
22121 Z_scripterrlog("Invalid Index passed to Screen->LayerInvisible[]: %d\n", indx);
22122 }
22123 else
22124 {
22125 if(value)
22126 tmpscr->hidelayers |= (1<<indx);
22127 else
22128 tmpscr->hidelayers &= ~(1<<indx);
22129 }
22130 break;
22131 }
22132 case SCREENDATASCRIPTDRAWS:
22133 {
22134 int32_t indx = ri->d[rINDEX] / 10000;
22135 if(indx < 0 || indx > 7 )
22136 {
22137 Z_scripterrlog("Invalid Index passed to Screen->HideScriptLayer[]: %d\n", indx);
22138 }
22139 else
22140 {
22141 if(value)
22142 tmpscr->hidescriptlayers &= ~(1<<indx);
22143 else
22144 tmpscr->hidescriptlayers |= (1<<indx);
22145 }
22146 break;
22147 }
22148
22149 case SCREENDATATILEWARPOVFLAGS:
22150 {
22151 int32_t indx = ri->d[rINDEX] / 10000;
22152 if ( ((unsigned)indx) > 3 )
22153 {
22154 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
22155 }
22156 else
22157 {
22158 if ( value ) tmpscr->tilewarpoverlayflags |= (1<<indx);
22159 else tmpscr->tilewarpoverlayflags &= ~(1<<indx);
22160 }
22161 break;
22162 }
22163
22164 case SCREENDATASIDEWARPOVFLAGS:
22165 {
22166 int32_t indx = ri->d[rINDEX] / 10000;
22167 if ( ((unsigned)indx) > 3 )
22168 {
22169 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
22170 }
22171 else
22172 {
22173 if ( value ) tmpscr->sidewarpoverlayflags |= (1<<indx);
22174 else tmpscr->sidewarpoverlayflags &= ~(1<<indx);
22175 }
22176 break;
22177 }
22178
22179 case SCREENDATATIMEDWARPTICS: SET_SCREENDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
22180 case SCREENDATANEXTMAP: SET_SCREENDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
22181 case SCREENDATANEXTSCREEN: SET_SCREENDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
22182 128 case SCREENDATASECRETCOMBO: SET_SCREENDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
22183 128 case SCREENDATASECRETCSET: SET_SCREENDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
22184 128 case SCREENDATASECRETFLAG: SET_SCREENDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
22185 case SCREENDATAVIEWX: break;//SET_SCREENDATA_VAR_INT32(viewX, "ViewX"); break; //W
22186 case SCREENDATAVIEWY: break;//SET_SCREENDATA_VAR_INT32(viewY, "ViewY"); break; //W
22187 case SCREENDATASCREENWIDTH: break;//SET_SCREENDATA_VAR_BYTE(scrWidth, "Width"); break; //B
22188 case SCREENDATASCREENHEIGHT: break;//SET_SCREENDATA_VAR_BYTE(scrHeight, "Height"); break; //B
22189 case SCREENDATAENTRYX:
22190 {
22191 5 int32_t newx = vbound((value/10000),0,255);
22192 5 tmpscr->entry_x = newx;
22193
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if ( get_qr(qr_WRITE_ENTRYPOINTS_AFFECTS_HEROCLASS) )
22194 {
22195 Hero.respawn_x = (zfix)(newx);
22196 }
22197 5 break;
22198 }
22199 case SCREENDATAENTRYY:
22200 {
22201
22202 5 int32_t newy = vbound((value/10000),0,175);
22203 5 tmpscr->entry_y = newy;
22204
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if ( get_qr(qr_WRITE_ENTRYPOINTS_AFFECTS_HEROCLASS) )
22205 {
22206 Hero.respawn_y = (zfix)(newy);
22207 }
22208 5 break; //B
22209 }
22210
22211 case SCREENDATANUMFF:
22212 {
22213 break;
22214 }
22215
22216 case SCREENDATAFFINITIALISED:
22217 {
22218 int32_t indx = ri->d[rINDEX] / 10000;
22219 if (indx < 0 || indx > MAXFFCS-1)
22220 {
22221 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), "FFCRunning");
22222 break;
22223 }
22224 get_script_engine_data(ScriptType::FFC, indx).initialized = (value/10000) ? true : false;
22225 }
22226 break;
22227
22228 case SCREENDATASCRIPTENTRY: SET_SCREENDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
22229 case SCREENDATASCRIPTOCCUPANCY: SET_SCREENDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
22230 case SCREENDATASCRIPTEXIT: SET_SCREENDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
22231 case SCREENDATAOCEANSFX:
22232 {
22233 int32_t v = vbound(value/10000, 0, 255);
22234 if(tmpscr->oceansfx != v)
22235 {
22236 stop_sfx(tmpscr->oceansfx);
22237 tmpscr->oceansfx = v;
22238 cont_sfx(tmpscr->oceansfx);
22239 }
22240 break;
22241 }
22242 case SCREENDATABOSSSFX: SET_SCREENDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
22243 case SCREENDATASECRETSFX: SET_SCREENDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
22244 case SCREENDATAHOLDUPSFX: SET_SCREENDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
22245 case SCREENDATASCREENMIDI:
22246 {
22247 tmpscr->screen_midi = vbound((value / 10000)-(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT),-1,32767);
22248 break;
22249 }
22250 case SCREENDATALENSLAYER: SET_SCREENDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
22251
22252 case SCREENSIDEWARPID:
22253 {
22254 int32_t indx = ri->d[rINDEX] / 10000; //dir
22255
22256 int32_t new_warp_return = vbound((value / 10000),-1,3); //none, A, B, C, D
22257 if(new_warp_return == -1)
22258 {
22259 tmpscr->flags2 &= ~(1<<indx); //Unset the "Enabled" flag for this dir
22260 tmpscr->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir as well.
22261 }
22262 else
22263 {
22264 tmpscr->flags2 |= 1<<indx; //Set the "Enabled" flag for this dir
22265 tmpscr->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir bits
22266 tmpscr->sidewarpindex |= (new_warp_return<<(2*indx)); //Set the new dir
22267 }
22268
22269 break;
22270 }
22271
22272 case SCREENDATATWARPRETSQR:
22273 {
22274 int32_t indx = ri->d[rINDEX] / 10000;
22275 if ( ((unsigned)indx) > 3)
22276 {
22277 Z_scripterrlog("Invalid Array Index passed to Screen->TileWarpReturnSquare[]: %d\n", indx);
22278 }
22279 else
22280 {
22281 int32_t wrindex = vbound(value/10000, 0, 3);
22282 tmpscr->warpreturnc = (tmpscr->warpreturnc&~(3<<(indx*2))) | (wrindex<<(indx*2));
22283 }
22284 break;
22285 }
22286
22287 //
22288 case SCREENDATASWARPRETSQR:
22289 {
22290
22291 int32_t indx = ri->d[rINDEX] / 10000;
22292 if ( ((unsigned)indx) > 3)
22293 {
22294 Z_scripterrlog("Invalid Array Index passed to Screen->SideWarpReturnSquare[]: %d\n", indx);
22295 }
22296 else
22297 {
22298 int32_t wrindex = vbound(value/10000, 0, 3);
22299 tmpscr->warpreturnc = (tmpscr->warpreturnc&~(3<<(8+(indx*2)))) | (wrindex<<(8+(indx*2)));
22300 }
22301 break;
22302 }
22303
22304
22305 case SCREENDATAFLAGS:
22306 {
22307 int32_t flagid = (ri->d[rINDEX])/10000;
22308 //bool valtrue = ( value ? 10000 : 0);
22309 switch(flagid)
22310 {
22311 case 0: tmpscr->flags = (value / 10000); break;
22312 case 1: tmpscr->flags2 = (value / 10000); break;
22313 case 2: tmpscr->flags3 = (value / 10000); break;
22314 case 3: tmpscr->flags4 = (value / 10000); break;
22315 case 4: tmpscr->flags5 = (value / 10000); break;
22316 case 5: tmpscr->flags6 = (value / 10000); break;
22317 case 6: tmpscr->flags7 = (value / 10000); break;
22318 case 7: tmpscr->flags8 = (value / 10000); break;
22319 case 8: tmpscr->flags9 = (value / 10000); break;
22320 case 9: tmpscr->flags10 = (value / 10000); break;
22321 default:
22322 {
22323 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
22324 break;
22325
22326 }
22327 }
22328 break;
22329 //GET_SCREENDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
22330 }
22331
22332 case SCREENDATAGUYCOUNT:
22333 {
22334 int mi = get_mi();
22335 if(mi > -1)
22336 game->guys[mi] = vbound(value/10000,10,0);
22337 break;
22338 }
22339
22340
22341 //These use the same method as SetScreenD
22342 case SCREENWIDTH:
22343 // FFScript::set_screenWidth(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22344 break;
22345
22346 case SCREENHEIGHT:
22347 // FFScript::set_screenHeight(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22348 break;
22349
22350 case SCREENVIEWX:
22351 // FFScript::set_screenViewX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22352 break;
22353
22354 case SCREENVIEWY:
22355 // FFScript::set_screenViewY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22356 break;
22357
22358 case SCREENGUY:
22359 FFScript::set_screenGuy(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22360 break;
22361
22362 case SCREENSTRING:
22363 {
22364 FFScript::set_screenString(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22365 //should this be either
22366 //set_screenString(&TheMaps[((ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)])-1), value/10000);
22367 //or
22368 //set_screenString(&TheMaps[((ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)])-+1), value/10000);
22369 Z_message("Map ref is: %d\n",((ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)));
22370 }
22371 break;
22372
22373 case SCREENROOM:
22374 FFScript::set_screenRoomtype(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22375 break;
22376
22377 case SCREENENTX:
22378 FFScript::set_screenEntryX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22379 break;
22380
22381 case SCREENENTY:
22382 FFScript::set_screenEntryY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22383 break;
22384
22385 case SCREENITEM:
22386 FFScript::set_screenitem(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22387 break;
22388
22389 case SCREENUNDCMB:
22390 FFScript::set_screenundercombo(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22391 break;
22392
22393 case SCREENUNDCST:
22394 FFScript::set_screenundercset(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22395 break;
22396
22397 case SCREENCATCH:
22398 FFScript::set_screenatchall(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22399 break;
22400
22401 //These use the method of SetScreenEnemy
22402
22403
22404 //SetScreenLayerOpacity(int32_t map, int32_t scr, int32_t layer, int32_t v)
22405 case SETSCREENLAYOP:
22406 {
22407 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22408 int32_t scrn = ri->d[rEXP1] / 10000;
22409 int32_t index = ri->d[rINDEX] / 10000;
22410 int32_t nn = ri->d[rEXP2]/10000;
22411
22412 if(BC::checkMapID(map, "Game->SetScreenLayerOpacity(...map...)") != SH::_NoError ||
22413 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenLayerOpacity(...screen...)") != SH::_NoError ||
22414 BC::checkBounds(index, 0, 9, "Game->SetScreenLayerOpacity(...index...)") != SH::_NoError)
22415 return;
22416
22417 FFScript::set_screenlayeropacity(&TheMaps[map * MAPSCRS + scrn], index, nn);
22418 }
22419 break;
22420
22421 case SETSCREENSECCMB:
22422 {
22423 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22424 int32_t scrn = ri->d[rEXP1] / 10000;
22425 int32_t index = ri->d[rINDEX] / 10000;
22426 int32_t nn = ri->d[rEXP2]/10000;
22427
22428 if(BC::checkMapID(map, "Game->SetScreenSecretCombo(...map...)") != SH::_NoError ||
22429 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenSecretCombo(...screen...)") != SH::_NoError ||
22430 BC::checkBounds(index, 0, 9, "Game->SetScreenSecretCombo(...index...)") != SH::_NoError)
22431 return;
22432
22433 FFScript::set_screensecretcombo(&TheMaps[map * MAPSCRS + scrn], index, nn);
22434 }
22435 break;
22436
22437 case SETSCREENSECCST:
22438 {
22439 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22440 int32_t scrn = ri->d[rEXP1] / 10000;
22441 int32_t index = ri->d[rINDEX] / 10000;
22442 int32_t nn = ri->d[rEXP2]/10000;
22443
22444 if(BC::checkMapID(map, "Game->SetScreenSecretCSet(...map...)") != SH::_NoError ||
22445 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenSecretCSet(...screen...)") != SH::_NoError ||
22446 BC::checkBounds(index, 0, 9, "Game->SetScreenSecretCSet(...index...)") != SH::_NoError)
22447 return;
22448
22449 FFScript::set_screensecretcset(&TheMaps[map * MAPSCRS + scrn], index, nn);
22450 }
22451 break;
22452
22453 case SETSCREENSECFLG:
22454 {
22455 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22456 int32_t scrn = ri->d[rEXP1] / 10000;
22457 int32_t index = ri->d[rINDEX] / 10000;
22458 int32_t nn = ri->d[rEXP2]/10000;
22459
22460 if(BC::checkMapID(map, "Game->SetScreenSecretFlag(...map...)") != SH::_NoError ||
22461 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenSecretFlag(...screen...)") != SH::_NoError ||
22462 BC::checkBounds(index, 0, 9, "Game->SetScreenSecretFlag(...index...)") != SH::_NoError)
22463 return;
22464
22465 FFScript::set_screensecretflag(&TheMaps[map * MAPSCRS + scrn], index, nn);
22466 }
22467 break;
22468
22469 case SETSCREENLAYMAP:
22470 {
22471 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22472 int32_t scrn = ri->d[rEXP1] / 10000;
22473 int32_t index = ri->d[rINDEX] / 10000;
22474 int32_t nn = ri->d[rEXP2]/10000;
22475
22476 if(BC::checkMapID(map, "Game->SetScreenLayerMap(...map...)") != SH::_NoError ||
22477 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenLayerMap(...screen...)") != SH::_NoError ||
22478 BC::checkBounds(index, 0, 9, "Game->SetScreenLayerMap(...index...)") != SH::_NoError)
22479 return;
22480
22481 FFScript::set_screenlayermap(&TheMaps[map * MAPSCRS + scrn], index, nn);
22482 }
22483 break;
22484
22485 case SETSCREENLAYSCR:
22486 {
22487 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22488 int32_t scrn = ri->d[rEXP1] / 10000;
22489 int32_t index = ri->d[rINDEX] / 10000;
22490 int32_t nn = ri->d[rEXP2]/10000;
22491
22492 if(BC::checkMapID(map, "Game->SetScreenLayerScreen(...map...)") != SH::_NoError ||
22493 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenLayerScreen(...screen...)") != SH::_NoError ||
22494 BC::checkBounds(index, 0, 9, "Game->SetScreenLayerScreen(...index...)") != SH::_NoError)
22495 return;
22496
22497 FFScript::set_screenlayerscreen(&TheMaps[map * MAPSCRS + scrn], index, nn);
22498 }
22499 break;
22500
22501 case SETSCREENPATH:
22502 {
22503 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22504 int32_t scrn = ri->d[rEXP1] / 10000;
22505 int32_t index = ri->d[rINDEX] / 10000;
22506 int32_t nn = ri->d[rEXP2]/10000;
22507
22508 if(BC::checkMapID(map, "Game->SetScreenPath(...map...)") != SH::_NoError ||
22509 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenPath(...screen...)") != SH::_NoError ||
22510 BC::checkBounds(index, 0, 9, "Game->SetScreenPath(...index...)") != SH::_NoError)
22511 return;
22512
22513 FFScript::set_screenpath(&TheMaps[map * MAPSCRS + scrn], index, nn);
22514 }
22515 break;
22516
22517 case SETSCREENWARPRX:
22518 {
22519 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22520 int32_t scrn = ri->d[rEXP1] / 10000;
22521 int32_t index = ri->d[rINDEX] / 10000;
22522 int32_t nn = ri->d[rEXP2]/10000;
22523
22524 if(BC::checkMapID(map, "Game->SetScreenWarpReturnX(...map...)") != SH::_NoError ||
22525 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenWarpReturnX(...screen...)") != SH::_NoError ||
22526 BC::checkBounds(index, 0, 9, "Game->SetScreenWarpReturnX(...index...)") != SH::_NoError)
22527 return;
22528
22529 FFScript::set_screenwarpReturnX(&TheMaps[map * MAPSCRS + scrn], index, nn);
22530 }
22531 break;
22532
22533 case SETSCREENWARPRY:
22534 {
22535 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22536 int32_t scrn = ri->d[rEXP1] / 10000;
22537 int32_t index = ri->d[rINDEX] / 10000;
22538 int32_t nn = ri->d[rEXP2]/10000;
22539
22540 if(BC::checkMapID(map, "Game->SetScreenWarpReturnY(...map...)") != SH::_NoError ||
22541 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenWarpReturnY(...screen...)") != SH::_NoError ||
22542 BC::checkBounds(index, 0, 9, "Game->SetScreenWarpReturnY(...index...)") != SH::_NoError)
22543 return;
22544
22545 FFScript::set_screenwarpReturnY(&TheMaps[map * MAPSCRS + scrn], index, nn);
22546 }
22547 break;
22548
22549 case SDD:
22550 {
22551 {
22552
2/2
✓ Branch 0 taken 14236 times.
✓ Branch 1 taken 41 times.
14277 int32_t di2 = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
22553 14277 FFScript::set_screen_d(di2, ri->d[rINDEX]/10000, value);
22554 14277 break;
22555 }
22556 }
22557
22558 case GDD:
22559 al_trace("GDD");
22560 game->global_d[ri->d[rINDEX]/10000]=value;
22561 break;
22562
22563 case SDDD:
22564 27297 FFScript::set_screen_d((ri->d[rINDEX])/10000 + ((get_currdmap())<<7), ri->d[rINDEX2]/10000, value);
22565 27297 break;
22566
22567 case SDDDD:
22568 531 FFScript::set_screen_d(ri->d[rINDEX2]/10000 + ((ri->d[rINDEX]/10000)<<7), ri->d[rEXP1]/10000, value);
22569 531 break;
22570
22571 case SCREENINITD:
22572 tmpscr->screeninitd[ri->d[rINDEX]/10000] = value;
22573 break;
22574
22575 case SCREENSCRIPT:
22576 {
22577 FFScript::deallocateAllScriptOwned(ScriptType::Screen, 0);
22578
22579 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
22580 {
22581 for(int32_t q=0; q<8; q++)
22582 tmpscr->screeninitd[q] = 0;
22583 }
22584 FFCore.ref(ScriptType::Screen, 0).Clear();
22585 tmpscr->script=vbound(value/10000, 0, NUMSCRIPTSCREEN-1);
22586 break;
22587 }
22588
22589 case MAPDATAINITD:
22590 tmpscr->screeninitd[ri->d[rINDEX]/10000]=value;
22591 break;
22592
22593 case SCRDOORD:
22594 4 tmpscr->door[ri->d[rINDEX]/10000]=value/10000;
22595 4 putdoor(scrollbuf,0,ri->d[rINDEX]/10000,value/10000,true,true);
22596 4 break;
22597
22598 case LIT:
22599 900 naturaldark = !value;
22600 900 lighting(false, false);
22601 900 break;
22602
22603 case WAVY:
22604 7214 wavy=value/10000;
22605 7214 break;
22606
22607 case QUAKE:
22608 3579 quakeclk=value/10000;
22609 3579 break;
22610
22611 case ROOMTYPE:
22612 tmpscr->room=value/10000; break; //this probably doesn't work too well...
22613
22614 case ROOMDATA:
22615 11 tmpscr->catchall=value/10000;
22616 11 break;
22617
22618 case PUSHBLOCKLAYER:
22619 mblock2.blockLayer=vbound(value/10000, 0, 6);
22620 break;
22621
22622 case PUSHBLOCKCOMBO:
22623 mblock2.bcombo=value/10000;
22624 break;
22625
22626 case PUSHBLOCKCSET:
22627 mblock2.cs=value/10000;
22628 mblock2.oldcset=value/10000;
22629 break;
22630
22631 case UNDERCOMBO:
22632 tmpscr->undercombo=value/10000;
22633 break;
22634
22635 case UNDERCSET:
22636 tmpscr->undercset=value/10000;
22637 break;
22638
22639
22640 case DEBUGGDR:
22641 {
22642 int32_t a = vbound(ri->d[rINDEX]/10000,0,15);
22643 game->global_d[a] = value / 10000;;
22644 break;
22645 }
22646
22647 case DEBUGSP:
22648 SH::write_stack(ri->sp,vbound((value / 10000),0,MAX_SCRIPT_REGISTERS-1));
22649 break;
22650
22651 case DEBUGREFFFC:
22652 ri->ffcref = vbound((value / 10000),1,MAXFFCS-1);
22653 break;
22654
22655 case DEBUGREFITEM:
22656 ri->itemref = vbound((value / 10000),0,255);
22657 break;
22658
22659 case DEBUGREFITEMDATA:
22660 ri->idata = vbound((value / 10000),0,255);
22661 break;
22662
22663 case DEBUGREFLWEAPON:
22664 ri->lwpn = vbound((value / 10000),0,255);
22665 break;
22666
22667 case DEBUGREFEWEAPON:
22668 ri->ewpn = vbound((value / 10000),0,255);
22669 break;
22670
22671 case DEBUGREFNPC:
22672 ri->guyref = vbound((value / 10000),0,255);
22673 break;
22674
22675
22676 //Game Over Screen
22677 case SETGAMEOVERELEMENT:
22678 {
22679 int32_t colour = value/10000;
22680 int32_t index = ri->d[rINDEX]/10000;
22681 index = vbound(index,0,SAVESC_LAST-1);
22682 // zprint("GameOverScreen Index,Value: %d,%ld/n",index,colour);
22683 SetSaveScreenSetting(index,colour);
22684 break;
22685 }
22686
22687 case SETGAMEOVERSTRING:
22688 {
22689 int32_t arrayptr = value/10000;
22690 int32_t index = ri->d[rINDEX]/10000;
22691 index = vbound(index,0,SAVESC_END-1);
22692 string filename_str;
22693 ArrayH::getString(arrayptr, filename_str, 73);
22694 ChangeSubscreenText(index,filename_str.c_str());
22695 break;
22696 }
22697
22698 ///----------------------------------------------------------------------------------------------------//
22699 //New Datatype Variables
22700
22701 ///----------------------------------------------------------------------------------------------------//
22702 //spritedata sp-> Variables
22703 case SPRITEDATATILE: SET_SPRITEDATA_VAR_INT(tile, "Tile"); break;
22704 case SPRITEDATAMISC: SET_SPRITEDATA_VAR_BYTE(misc, "Misc"); break;
22705 case SPRITEDATACSETS:
22706 {
22707 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
22708 {
22709 Z_scripterrlog("Invalid Sprite ID passed to spritedata->CSet: %d\n", (ri->spritesref*10000));
22710 }
22711 else
22712 {
22713 wpnsbuf[ri->spritesref].csets &= 0xF0;
22714 wpnsbuf[ri->spritesref].csets |= vbound((value / 10000),0,15);
22715 }
22716 break;
22717 }
22718 case SPRITEDATAFLCSET:
22719 {
22720 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
22721 {
22722 Z_scripterrlog("Invalid Sprite ID passed to spritedata->FlashCSet: %d\n", (ri->spritesref*10000));
22723 }
22724 else
22725 {
22726 wpnsbuf[ri->spritesref].csets &= 0x0F;
22727 wpnsbuf[ri->spritesref].csets |= vbound((value / 10000),0,15)<<4;
22728 }
22729 break;
22730 }
22731 case SPRITEDATAFRAMES: SET_SPRITEDATA_VAR_BYTE(frames, "Frames"); break;
22732 case SPRITEDATASPEED: SET_SPRITEDATA_VAR_BYTE(speed, "Speed"); break;
22733 case SPRITEDATATYPE: SET_SPRITEDATA_VAR_BYTE(type, "Type"); break;
22734 case SPRITEDATAFLAGS:
22735 {
22736 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
22737 {
22738 Z_scripterrlog("Invalid Sprite ID passed to spritedata->Flags[]: %d\n", (ri->spritesref*10000));
22739 break;
22740 }
22741 int32_t index = ri->d[rINDEX]/10000;
22742 if(unsigned(index) >= 5)
22743 {
22744 Z_scripterrlog("Invalid index passed to spritedata->Flags[]: %d\n", index);
22745 break;
22746 }
22747 SETFLAG(wpnsbuf[ri->spritesref].misc, 1<<index, value);
22748 break;
22749 }
22750
22751 ///----------------------------------------------------------------------------------------------------//
22752 //mapdata m-> Variables
22753 //mapdata m-> Variables
22754
22755 #define SET_MAPDATA_VAR_INT32(member, str) \
22756 { \
22757 if (mapscr *m = GetMapscr(ri->mapsref)) \
22758 { \
22759 m->member = vbound((value / 10000),-214747,214747); \
22760 } \
22761 else \
22762 { \
22763 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22764 } \
22765 break; \
22766 } \
22767
22768 #define SET_MAPDATA_VAR_INT16(member, str) \
22769 { \
22770 if (mapscr *m = GetMapscr(ri->mapsref)) \
22771 { \
22772 m->member = vbound((value / 10000),0,32767); \
22773 } \
22774 else \
22775 { \
22776 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22777 } \
22778 break; \
22779 } \
22780
22781 #define SET_MAPDATA_VAR_BYTE(member, str) \
22782 { \
22783 if (mapscr *m = GetMapscr(ri->mapsref)) \
22784 { \
22785 m->member = vbound((value / 10000),0,255); \
22786 } \
22787 else \
22788 { \
22789 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22790 } \
22791 break; \
22792 } \
22793
22794 #define SET_MAPDATA_VAR_INDEX32(member, str, indexbound) \
22795 { \
22796 int32_t indx = ri->d[rINDEX] / 10000; \
22797 if(indx < 0 || indx > indexbound ) \
22798 { \
22799 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22800 } \
22801 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22802 { \
22803 m->member[indx] = vbound((value / 10000),-214747,214747); \
22804 } \
22805 else \
22806 { \
22807 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22808 } \
22809 break; \
22810 } \
22811
22812 #define SET_MAPDATA_VAR_INDEX16(member, str, indexbound) \
22813 { \
22814 int32_t indx = ri->d[rINDEX] / 10000; \
22815 if(indx < 0 || indx > indexbound ) \
22816 { \
22817 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22818 } \
22819 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22820 { \
22821 m->member[indx] = vbound((value / 10000),-32767,32767); \
22822 } \
22823 else \
22824 { \
22825 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22826 } \
22827 break; \
22828 } \
22829
22830 #define SET_MAPDATA_BYTE_INDEX(member, str, indexbound) \
22831 { \
22832 int32_t indx = ri->d[rINDEX] / 10000; \
22833 if(indx < 0 || indx > indexbound ) \
22834 { \
22835 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22836 } \
22837 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22838 { \
22839 m->member[indx] = vbound((value / 10000),0,255); \
22840 } \
22841 else \
22842 { \
22843 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22844 } \
22845 break; \
22846 }\
22847
22848 #define SET_MAPDATA_LAYER_INDEX(member, str, indexbound) \
22849 { \
22850 int32_t indx = ri->d[rINDEX] / 10000; \
22851 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
22852 if(indx < 1 || indx > indexbound ) \
22853 { \
22854 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22855 } \
22856 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22857 { \
22858 m->member[indx-1] = vbound((value / 10000),0,255); \
22859 } \
22860 else \
22861 { \
22862 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22863 } \
22864 break; \
22865 } \
22866
22867 #define SET_MAPDATA_LAYERSCREEN_INDEX(member, str, indexbound) \
22868 { \
22869 int32_t indx = ri->d[rINDEX] / 10000; \
22870 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
22871 int32_t scrn_id = value/10000; \
22872 if(indx < 1 || indx > indexbound ) \
22873 { \
22874 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22875 } \
22876 else if ( scrn_id > MAPSCRS ) \
22877 { \
22878 Z_scripterrlog("Script attempted to use a mapdata->LayerScreen[%d].\n",scrn_id); \
22879 Z_scripterrlog("Valid Screen values are (0) through (%d).\n",MAPSCRS); \
22880 } \
22881 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22882 { \
22883 m->member[indx-1] = vbound((scrn_id),0,MAPSCRS); \
22884 } \
22885 else \
22886 { \
22887 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22888 } \
22889 break; \
22890 }\
22891
22892 #define SET_MAPDATA_BOOL_INDEX(member, str, indexbound) \
22893 { \
22894 int32_t indx = ri->d[rINDEX] / 10000; \
22895 if(indx < 0 || indx > indexbound ) \
22896 { \
22897 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22898 } \
22899 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22900 { \
22901 m->member[indx] =( (value/10000) ? 1 : 0 ); \
22902 } \
22903 else \
22904 { \
22905 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22906 } \
22907 break; \
22908 } \
22909
22910 #define SET_FFC_MAPDATA_BOOL_INDEX(member, str, indexbound) \
22911 { \
22912 int32_t indx = ri->d[rINDEX] / 10000; \
22913 if(indx < 0 || indx > indexbound ) \
22914 { \
22915 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22916 } \
22917 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22918 { \
22919 m->ffcs[indx].member =( (value/10000) ? 1 : 0 ); \
22920 } \
22921 else \
22922 { \
22923 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22924 } \
22925 break; \
22926 } \
22927
22928 #define SET_MAPDATA_FLAG(member, str) \
22929 { \
22930 int32_t flag = (value/10000); \
22931 if (mapscr *m = GetMapscr(ri->mapsref)) \
22932 { \
22933 if ( flag != 0 ) \
22934 { \
22935 m->member|=flag; \
22936 } \
22937 else m->.member|= ~flag; \
22938 } \
22939 else \
22940 { \
22941 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22942 } \
22943 break; \
22944 } \
22945
22946 #define SET_MAPDATA_FFCPOS_INDEX32(member, str, indexbound) \
22947 { \
22948 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
22949 if(indx < 0 || indx > indexbound ) \
22950 { \
22951 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
22952 } \
22953 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22954 { \
22955 m->ffcs[indx].member = zslongToFix(value); \
22956 } \
22957 else \
22958 { \
22959 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
22960 } \
22961 break; \
22962 } \
22963
22964 #define SET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
22965 { \
22966 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
22967 if(indx < 0 || indx > indexbound ) \
22968 { \
22969 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
22970 } \
22971 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22972 { \
22973 m->ffcs[indx].member = value/10000; \
22974 } \
22975 else \
22976 { \
22977 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
22978 } \
22979 break; \
22980 } \
22981
22982 #define SET_MAPDATA_FFC_INDEX_VBOUND(member, str, indexbound, min, max) \
22983 { \
22984 int32_t v = value/10000; \
22985 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
22986 if(indx < 0 || indx > indexbound ) \
22987 { \
22988 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
22989 } \
22990 else if(v < min || v > max ) \
22991 { \
22992 Z_scripterrlog("Invalid value assigned to mapdata->%s[]: %d\n", (indx+1), str); \
22993 } \
22994 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22995 { \
22996 m->ffcs[indx].member = v; \
22997 } \
22998 else \
22999 { \
23000 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
23001 } \
23002 break; \
23003 } \
23004
23005 case MAPDATAVALID: SET_MAPDATA_VAR_BYTE(valid, "Valid"); break; //b
23006 case MAPDATAGUY: SET_MAPDATA_VAR_BYTE(guy, "Guy"); break; //b
23007 case MAPDATASTRING: SET_MAPDATA_VAR_INT32(str, "String"); break; //w
23008 case MAPDATAROOM: SET_MAPDATA_VAR_BYTE(room, "RoomType"); break; //b
23009 case MAPDATAITEM:
23010 {
23011 if (mapscr *m = GetMapscr(ri->mapsref))
23012 {
23013 auto v = vbound((value / 10000),-1,255);
23014 if(v > -1)
23015 m->item = v;
23016 m->hasitem = v > -1;
23017 }
23018 else
23019 {
23020 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Item");
23021 }
23022 break;
23023 }
23024 case MAPDATAHASITEM: SET_MAPDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
23025 case MAPDATATILEWARPTYPE: SET_MAPDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
23026 //case MAPDATATILEWARPOVFLAGS: SET_MAPDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
23027 case MAPDATADOORCOMBOSET: SET_MAPDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
23028 case MAPDATAWARPRETX: SET_MAPDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
23029 case MAPDATAWARPRETY: SET_MAPDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
23030 case MAPDATAWARPRETURNC: SET_MAPDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
23031 case MAPDATASTAIRX: SET_MAPDATA_VAR_BYTE(stairx, "StairsX"); break; //b
23032 case MAPDATASTAIRY: SET_MAPDATA_VAR_BYTE(stairy, "StairsY"); break; //b
23033 case MAPDATAITEMX: SET_MAPDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
23034 case MAPDATAITEMY: SET_MAPDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
23035 case MAPDATACOLOUR: SET_MAPDATA_VAR_INT32(color, "CSet"); break; //w
23036 case MAPDATAENEMYFLAGS: SET_MAPDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
23037 case MAPDATADOOR: SET_MAPDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
23038 case MAPDATATILEWARPDMAP: SET_MAPDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
23039 case MAPDATATILEWARPSCREEN: SET_MAPDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
23040 case MAPDATAEXITDIR: SET_MAPDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
23041 case MAPDATAENEMY:
23042 {
23043 int32_t indx = (ri->d[rINDEX] / 10000);
23044 int32_t enemyid = value/10000;
23045 if( ((unsigned)indx) > 9 )
23046 {
23047 Z_scripterrlog("Invalid Index passed to mapdata->%s: %d\n", "Enemy[]", (indx));
23048 }
23049 else if ( ((unsigned)enemyid) > MAXGUYS )
23050 {
23051 Z_scripterrlog("Invaid enemy ID (%d) passed to Mapdata->%s.", enemyid,"Enemy[]");
23052 }
23053 else if (mapscr *m = GetMapscr(ri->mapsref))
23054 {
23055 m->enemy[indx] = enemyid;
23056 }
23057 else
23058 {
23059 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","Enemy[]");
23060 }
23061 break;
23062 }
23063 //case MAPDATAENEMY: SET_MAPDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
23064 case MAPDATAPATTERN: SET_MAPDATA_VAR_BYTE(pattern, "Pattern"); break; //b
23065 case MAPDATASIDEWARPTYPE: SET_MAPDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
23066 //case MAPDATASIDEWARPOVFLAGS: SET_MAPDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
23067 case MAPDATAWARPARRIVALX: SET_MAPDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
23068 case MAPDATAWARPARRIVALY: SET_MAPDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
23069 case MAPDATAPATH: SET_MAPDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
23070 case MAPDATASIDEWARPSC: SET_MAPDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
23071 case MAPDATAINITDARRAY:
23072 {
23073
23074 if (mapscr *m = GetMapscr(ri->mapsref))
23075 {
23076 m->screeninitd[ri->d[rINDEX]/10000] = value;
23077 }
23078 else
23079 {
23080 Z_scripterrlog("Script attempted to use a mapdata->InitD[%d] on a pointer that is uninitialised\n",ri->d[rINDEX]/10000);
23081 }
23082 break;
23083 }
23084
23085
23086 case MAPDATALAYERINVIS:
23087 {
23088 int32_t indx = ri->d[rINDEX] / 10000;
23089 if(indx < 0 || indx > 6 )
23090 {
23091 Z_scripterrlog("Invalid Index passed to mapdata->LayerInvisible[]: %d\n", indx);
23092 }
23093 else
23094 {
23095
23096 if (mapscr *m = GetMapscr(ri->mapsref))
23097 {
23098 if(value)
23099 {
23100 tmpscr->hidelayers |= (1<<indx);
23101 }
23102 else
23103 {
23104 tmpscr->hidelayers &= ~(1<<indx);
23105 }
23106 }
23107 else
23108 {
23109 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","LayerInvisible");
23110 }
23111 }
23112 break;
23113 }
23114 case MAPDATASCRIPTDRAWS:
23115 {
23116 int32_t indx = ri->d[rINDEX] / 10000;
23117 if(indx < 0 || indx > 7 )
23118 {
23119 Z_scripterrlog("Invalid Index passed to mapdata->DisableScriptDraw[]: %d\n", indx);
23120 }
23121 else
23122 {
23123 if (mapscr *m = GetMapscr(ri->mapsref))
23124 {
23125 if(value)
23126 {
23127 tmpscr->hidescriptlayers &= ~(1<<indx);
23128 }
23129 else
23130 {
23131 tmpscr->hidescriptlayers |= (1<<indx);
23132 }
23133 }
23134 else
23135 {
23136 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","DisableScriptDraw");
23137 }
23138 }
23139 break;
23140 }
23141
23142 case MAPDATATILEWARPOVFLAGS:
23143 {
23144 int32_t indx = ri->d[rINDEX] / 10000;
23145 if ( ((unsigned)indx) > 3 )
23146 {
23147 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
23148 }
23149 else if (mapscr *m = GetMapscr(ri->mapsref))
23150 {
23151 if ( value ) m->tilewarpoverlayflags |= (1<<indx);
23152 else m->tilewarpoverlayflags &= ~(1<<indx);
23153 }
23154 else
23155 {
23156 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
23157 }
23158 break;
23159 }
23160
23161 case MAPDATASIDEWARPOVFLAGS:
23162 {
23163 int32_t indx = ri->d[rINDEX] / 10000;
23164 if ( ((unsigned)indx) > 3 )
23165 {
23166 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
23167 }
23168 else if (mapscr *m = GetMapscr(ri->mapsref))
23169 {
23170 if ( value ) m->sidewarpoverlayflags |= (1<<indx);
23171 else m->sidewarpoverlayflags &= ~(1<<indx);
23172 }
23173 else
23174 {
23175 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
23176 }
23177 break;
23178 }
23179
23180 case MAPDATASIDEWARPDMAP: SET_MAPDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
23181 case MAPDATASIDEWARPINDEX: SET_MAPDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
23182 case MAPDATAUNDERCOMBO: SET_MAPDATA_VAR_INT32(undercombo, "UnderCombo"); break; //w
23183 case MAPDATAUNDERCSET: SET_MAPDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
23184 case MAPDATACATCHALL: SET_MAPDATA_VAR_INT32(catchall, "Catchall"); break; //W
23185
23186 case MAPDATACSENSITIVE: SET_MAPDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
23187 case MAPDATANORESET: SET_MAPDATA_VAR_INT32(noreset, "NoReset"); break; //W
23188 case MAPDATANOCARRY: SET_MAPDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
23189 //! Layer arrays should be a size of 7, and return the current screen / map / and OP_OPAQUE
23190 //! if you try to read 0, so that they correspond to actual layer IDs.
23191 //!
23192 case MAPDATALAYERMAP: SET_MAPDATA_LAYER_INDEX(layermap, "LayerMap", 6); break; //B, 6 OF THESE
23193 case MAPDATALAYERSCREEN: SET_MAPDATA_LAYERSCREEN_INDEX(layerscreen, "LayerScreen", 6); break; //B, 6 OF THESE
23194 case MAPDATALAYEROPACITY: SET_MAPDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 6); break; //B, 6 OF THESE
23195 case MAPDATATIMEDWARPTICS: SET_MAPDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
23196 case MAPDATANEXTMAP: SET_MAPDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
23197 case MAPDATANEXTSCREEN: SET_MAPDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
23198 case MAPDATASECRETCOMBO: SET_MAPDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
23199 case MAPDATASECRETCSET: SET_MAPDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
23200 case MAPDATASECRETFLAG: SET_MAPDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
23201 case MAPDATAVIEWX: break;//SET_MAPDATA_VAR_INT32(viewX, "ViewX"); break; //W
23202 case MAPDATASCRIPT:
23203 {
23204 if (mapscr *m = GetMapscr(ri->mapsref))
23205 {
23206 if(ri->mapsref == MAPSCR_TEMP0) //This mapsref references tmpscr, so can reference a running script!
23207 {
23208 FFScript::deallocateAllScriptOwned(ScriptType::Screen, 0);
23209
23210 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
23211 {
23212 for(int32_t q=0; q<8; q++)
23213 tmpscr->screeninitd[q] = 0;
23214 }
23215
23216 FFCore.ref(ScriptType::Screen, 0).Clear();
23217 }
23218 m->script=vbound(value/10000, 0, NUMSCRIPTSCREEN-1);
23219 }
23220 else
23221 {
23222 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Script");
23223 }
23224 break;
23225
23226 }
23227 case MAPDATAVIEWY: break;//SET_MAPDATA_VAR_INT32(viewY, "ViewY"); break; //W
23228 case MAPDATASCREENWIDTH: break;//SET_MAPDATA_VAR_BYTE(scrWidth, "Width"); break; //B
23229 case MAPDATASCREENHEIGHT: break;//SET_MAPDATA_VAR_BYTE(scrHeight, "Height"); break; //B
23230 case MAPDATAENTRYX: SET_MAPDATA_VAR_BYTE(entry_x, "EntryX"); break; //B
23231 case MAPDATAENTRYY: SET_MAPDATA_VAR_BYTE(entry_y, "EntryY"); break; //B
23232 case MAPDATAFFDATA:
23233 {
23234 int32_t indx = (ri->d[rINDEX] / 10000)-1;
23235 if(indx < 0 || indx > MAXFFCS-1 )
23236 {
23237 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), "FFCData");
23238 }
23239 else if (mapscr *m = GetMapscr(ri->mapsref))
23240 {
23241 zc_ffc_set(m->ffcs[indx], value/10000);
23242 }
23243 else
23244 {
23245 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised", "FFCData");
23246 }
23247 break; //W, MAXFFCS OF THESE
23248 }
23249 case MAPDATAFFCSET: SET_MAPDATA_FFC_INDEX32(cset, "FFCCSet", MAXFFCS-1); break; //B, MAXFFCS
23250 case MAPDATAFFDELAY: SET_MAPDATA_FFC_INDEX32(delay, "FFCDelay", MAXFFCS-1); break; //W, MAXFFCS
23251 case MAPDATAFFX: SET_MAPDATA_FFCPOS_INDEX32(x, "FFCX", MAXFFCS-1); break; //INT32, MAXFFCS OF THESE
23252 case MAPDATAFFY: SET_MAPDATA_FFCPOS_INDEX32(y, "FFCY", MAXFFCS-1); break; //..
23253 case MAPDATAFFXDELTA: SET_MAPDATA_FFCPOS_INDEX32(vx, "FFCVx", MAXFFCS-1); break; //..
23254 case MAPDATAFFYDELTA: SET_MAPDATA_FFCPOS_INDEX32(vy, "FFCVy", MAXFFCS-1); break; //..
23255 case MAPDATAFFXDELTA2: SET_MAPDATA_FFCPOS_INDEX32(ax, "FFCAx", MAXFFCS-1); break; //..
23256 case MAPDATAFFYDELTA2: SET_MAPDATA_FFCPOS_INDEX32(ay, "FFCAy", MAXFFCS-1); break; //..
23257
23258 case MAPDATAFFFLAGS:
23259 {
23260 int32_t indx = (ri->d[rINDEX] / 10000)-1;
23261 if(indx < 0 || indx > MAXFFCS-1)
23262 {
23263 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), "FFCFlags");
23264 }
23265 else if (mapscr *m = GetMapscr(ri->mapsref))
23266 {
23267 m->ffcs[indx].flags = value/10000;
23268 m->ffcs[indx].updateSolid();
23269 }
23270 else
23271 {
23272 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCFlags");
23273 }
23274 break;
23275 }
23276
23277 //Number of ffcs that are in use (have valid data
23278 case MAPDATANUMFF:
23279 {
23280 break;
23281 }
23282
23283 case MAPDATASIDEWARPID:
23284 {
23285
23286 int32_t indx = ri->d[rINDEX] / 10000; //dir
23287 if (mapscr *m = GetMapscr(ri->mapsref))
23288 {
23289 int32_t new_warp_return = vbound((value / 10000),-1,3); //none, A, B, C, D
23290 if(new_warp_return == -1)
23291 {
23292 m->flags2 &= ~(1<<indx); //Unset the "Enabled" flag for this dir
23293 m->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir as well.
23294 }
23295 else
23296 {
23297 m->flags2 |= 1<<indx; //Set the "Enabled" flag for this dir
23298 m->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir bits
23299 m->sidewarpindex |= (new_warp_return<<(2*indx)); //Set the new dir
23300 }
23301 }
23302 else
23303 {
23304 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","SideWarpID");
23305 }
23306 break;
23307 }
23308
23309 case MAPDATATWARPRETSQR:
23310 {
23311 int32_t indx = ri->d[rINDEX] / 10000;
23312 if ( ((unsigned)indx) > 3)
23313 {
23314 Z_scripterrlog("Invalid Array Index passed to mapdata->TileWarpReturnSquare[]: %d\n", indx);
23315 }
23316 else if (mapscr *m = GetMapscr(ri->mapsref))
23317 {
23318 int32_t wrindex = vbound(value/10000, 0, 3);
23319 m->warpreturnc = (m->warpreturnc&~(3<<(indx*2))) | (wrindex<<(indx*2));
23320 }
23321 else
23322 {
23323 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
23324 }
23325 break;
23326 }
23327
23328 //
23329 case MAPDATASWARPRETSQR:
23330 {
23331
23332 int32_t indx = ri->d[rINDEX] / 10000;
23333 if ( ((unsigned)indx) > 3)
23334 {
23335 Z_scripterrlog("Invalid Array Index passed to MAPDATA->SideWarpReturnSquare[]: %d\n", indx);
23336 }
23337 else if (mapscr *m = GetMapscr(ri->mapsref))
23338 {
23339 int32_t wrindex = vbound(value/10000, 0, 3);
23340 m->warpreturnc = (m->warpreturnc&~(3<<(8+(indx*2)))) | (wrindex<<(8+(indx*2)));
23341 }
23342 else
23343 {
23344 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
23345 }
23346 break;
23347 }
23348
23349 case MAPDATAFFWIDTH:
23350 {
23351 int32_t indx = (ri->d[rINDEX] / 10000)-1;
23352 if ( indx < 0 || indx > MAXFFCS-1 )
23353 {
23354 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileWidth[]: %d\n", indx+1);
23355 }
23356 else if ( (value/10000) < 0 || (value/10000) > 4 )
23357 {
23358 Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCTileWidth[]: %d\n", value/10000);
23359 }
23360 else if (mapscr *m = GetMapscr(ri->mapsref))
23361 {
23362 m->ffTileWidth(indx, (value/10000));
23363 }
23364 else
23365 {
23366 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileWidth[]");
23367 }
23368 break;
23369 }
23370
23371 case MAPDATAFFHEIGHT:
23372 {
23373 int32_t indx = (ri->d[rINDEX] / 10000)-1;
23374 if ( indx < 0 || indx > MAXFFCS-1 )
23375 {
23376 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileHeight[]: %d\n", indx+1);
23377 }
23378 else if ( (value/10000) < 0 || (value/10000) > 4 )
23379 {
23380 Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCTileHeight[]: %d\n", value/10000);
23381 }
23382 else if (mapscr *m = GetMapscr(ri->mapsref))
23383 {
23384 m->ffTileHeight(indx, (value/10000));
23385 }
23386 else
23387 {
23388 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileHeight[]");
23389 }
23390 break;
23391
23392 }
23393
23394 case MAPDATAFFEFFECTWIDTH:
23395 {
23396 int32_t indx = (ri->d[rINDEX] / 10000)-1;
23397 if ( indx < 0 || indx > MAXFFCS-1 )
23398 {
23399 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectWidth[]: %d\n", indx+1);
23400 }
23401 else if ( (value/10000) < 0 )
23402 {
23403 Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCEffectWidth[]: %d\n", value/10000);
23404 }
23405 else if (mapscr *m = GetMapscr(ri->mapsref))
23406 {
23407 m->ffEffectWidth(indx, (value/10000));
23408 }
23409 else
23410 {
23411 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectWidth[]");
23412 }
23413 break;
23414 }
23415
23416 case MAPDATAFFEFFECTHEIGHT:
23417 {
23418 int32_t indx = (ri->d[rINDEX] / 10000)-1;
23419 if ( indx < 0 || indx > MAXFFCS-1 )
23420 {
23421 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectHeight[]: %d\n", indx+1);
23422 }
23423 else if ( (value/10000) < 0 )
23424 {
23425 Z_scripterrlog("Invalid HEIGHT value passed to MapData->FFCEffectHeight[]: %d\n", value/10000);
23426 }
23427 else if (mapscr *m = GetMapscr(ri->mapsref))
23428 {
23429 m->ffEffectHeight(indx, (value/10000));
23430 }
23431 else
23432 {
23433 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectHeight[]");
23434 }
23435 break;
23436 }
23437
23438 case MAPDATAFFLINK: SET_MAPDATA_FFC_INDEX_VBOUND(link, "FFCLink", MAXFFCS-1, 0, MAXFFCS); break; //B, MAXFFCS OF THESE
23439 case MAPDATAFFSCRIPT: SET_MAPDATA_FFC_INDEX_VBOUND(script, "FFCScript", MAXFFCS-1, 0, 255); break; //W, 32 OF THESE
23440
23441 case MAPDATAINTID: //Same form as SetScreenD()
23442 //SetFFCInitD(ffindex, d, value)
23443 {
23444 if (mapscr *m = GetMapscr(ri->mapsref))
23445 {
23446 //int32_t ffindex = ri->d[rINDEX]/10000;
23447 //int32_t d = ri->d[rINDEX2]/10000;
23448 //int32_t v = (value/10000);
23449 int32_t ffid = (ri->d[rINDEX]/10000) -1;
23450 int32_t indx = ri->d[rINDEX2]/10000;
23451
23452 if ( (unsigned)ffid > MAXFFCS-1 )
23453 {
23454 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
23455 }
23456 else if ( (unsigned)indx > 7 )
23457 {
23458 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
23459 }
23460 else
23461 {
23462 m->ffcs[ffid].initd[indx] = value;
23463 }
23464 }
23465 else
23466 {
23467 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","SetFFCInitD()");
23468 }
23469 break;
23470 }
23471
23472
23473 //initd //INT32 , 32 OF THESE, EACH WITH 10 INDICES.
23474
23475
23476 case MAPDATAINITA:
23477 //same form as SetScreenD
23478 {
23479 if (mapscr *m = GetMapscr(ri->mapsref))
23480 {//int32_t ffindex = ri->d[rINDEX]/10000;
23481 //int32_t d = ri->d[rINDEX2]/10000;
23482 //int32_t v = (value/10000);
23483 int32_t ffid = (ri->d[rINDEX]/10000) -1;
23484 int32_t indx = ri->d[rINDEX2]/10000;
23485
23486 if ( (unsigned)ffid > MAXFFCS-1 )
23487 {
23488 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
23489 }
23490 else if ( (unsigned)indx > 7 )
23491 {
23492 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
23493 }
23494 else
23495 {
23496 m->ffcs[ffid].inita[indx] = value;
23497 }
23498 }
23499 else
23500 {
23501 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","SetFFCInitA()");
23502 }
23503 break;
23504 }
23505
23506 case MAPDATAFFINITIALISED:
23507 {
23508 int32_t indx = ri->d[rINDEX] / 10000;
23509 if(indx < 0 || indx > MAXFFCS-1)
23510 {
23511 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", "FFCRunning", indx);
23512 }
23513 else if (mapscr *m = GetMapscr(ri->mapsref))
23514 {
23515 get_script_engine_data(ScriptType::FFC, indx).initialized = (value/10000) ? true : false;
23516 }
23517 else
23518 {
23519 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n", "FFCRunning");
23520 }
23521 }
23522 break;
23523
23524 case MAPDATASCRIPTENTRY: SET_MAPDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
23525 case MAPDATASCRIPTOCCUPANCY: SET_MAPDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
23526 case MAPDATASCRIPTEXIT: SET_MAPDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
23527 case MAPDATAOCEANSFX:
23528 {
23529 if (mapscr *m = GetMapscr(ri->mapsref))
23530 {
23531 int32_t v = vbound(value/10000, 0, 255);
23532 if(m == tmpscr && m->oceansfx != v)
23533 {
23534 stop_sfx(m->oceansfx);
23535 m->oceansfx = v;
23536 cont_sfx(m->oceansfx);
23537 }
23538 else m->oceansfx = v;
23539 }
23540 else
23541 {
23542 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","OceanSFX");
23543 }
23544 break;
23545 }
23546 case MAPDATABOSSSFX: SET_MAPDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
23547 case MAPDATASECRETSFX: SET_MAPDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
23548 case MAPDATAHOLDUPSFX: SET_MAPDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
23549 case MAPDATASCREENMIDI:
23550 {
23551 if (mapscr *m = GetMapscr(ri->mapsref))
23552 {
23553 m->screen_midi = vbound((value / 10000)-(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT),-1,32767);
23554 }
23555 else
23556 {
23557 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","MIDI");
23558 }
23559 break;
23560 }
23561 case MAPDATALENSLAYER: SET_MAPDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
23562
23563
23564 case MAPDATAFLAGS:
23565 {
23566 int32_t flagid = (ri->d[rINDEX])/10000;
23567 //bool valtrue = ( value ? 10000 : 0);
23568 if(mapscr *m = GetMapscr(ri->mapsref))
23569 {
23570 switch(flagid)
23571 {
23572 case 0: m->flags = (value / 10000); break;
23573 case 1: m->flags2 = (value / 10000); break;
23574 case 2: m->flags3 = (value / 10000); break;
23575 case 3: m->flags4 = (value / 10000); break;
23576 case 4: m->flags5 = (value / 10000); break;
23577 case 5: m->flags6 = (value / 10000); break;
23578 case 6: m->flags7 = (value / 10000); break;
23579 case 7: m->flags8 = (value / 10000); break;
23580 case 8: m->flags9 = (value / 10000); break;
23581 case 9: m->flags10 = (value / 10000); break;
23582 default:
23583 {
23584 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
23585 break;
23586 }
23587 }
23588 }
23589 else
23590 {
23591 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Flags[]");
23592 }
23593 break;
23594 //SET_MAPDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
23595 }
23596
23597 case MAPDATAMISCD:
23598 {
23599 if(mapscr* m = GetMapscr(ri->mapsref))
23600 {
23601 int32_t indx = (ri->d[rINDEX])/10000;
23602 int32_t mi = get_mi(ri->mapsref);
23603 if(mi<0) break;
23604 if( ((unsigned)indx) > 7 )
23605 {
23606 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", indx);
23607 break;
23608 }
23609 else
23610 {
23611 game->screen_d[mi][indx] = value/10000;
23612 break;
23613 }
23614 }
23615 else
23616 {
23617 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","D[]");
23618 }
23619 break;
23620 }
23621
23622
23623 case MAPDATACOMBODD:
23624 {
23625 80782 int32_t pos = (ri->d[rINDEX])/10000;
23626 80782 int32_t val = (value/10000);
23627
23628
1/2
✓ Branch 0 taken 80782 times.
✗ Branch 1 not taken.
80782 if(mapscr *m = GetMapscr(ri->mapsref))
23629 {
23630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80782 times.
80782 if ( ((unsigned) pos) > 175 )
23631 {
23632 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboD[]\n", pos);
23633 }
23634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80782 times.
80782 else if ( ((unsigned) val) >= MAXCOMBOS )
23635 {
23636 Z_scripterrlog("Invalid combo ID %d used to write to mapdata->ComboD[]\n", val);
23637 }
23638 else
23639 {
23640 80782 screen_combo_modify_preroutine(m,pos);
23641 80782 m->data[pos]=val;
23642 80782 screen_combo_modify_postroutine(m,pos);
23643 }
23644 80782 }
23645 else
23646 {
23647 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboD[]");
23648 }
23649 }
23650 80782 break;
23651
23652 case MAPDATACOMBOCD:
23653 {
23654 2497 int32_t pos = (ri->d[rINDEX])/10000;
23655 2497 int32_t val = (value/10000); //cset
23656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2497 times.
2497 if(mapscr *m = GetMapscr(ri->mapsref))
23657 {
23658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2497 times.
2497 if ( ((unsigned) pos) > 175 )
23659 {
23660 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboC[]\n", pos);
23661 }
23662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2497 times.
2497 else if ( ((unsigned) val) >= 15 )
23663 {
23664 Z_scripterrlog("Invalid CSet ID %d used to write to mapdata->ComboC[]\n", val);
23665 }
23666 else
23667 {
23668 2497 screen_combo_modify_preroutine(m,pos);
23669 2497 m->cset[pos]=(val)&15;
23670 2497 screen_combo_modify_postroutine(m,pos);
23671 }
23672 2497 }
23673 else
23674 {
23675 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboC[]");
23676 }
23677 }
23678 2497 break;
23679
23680 case MAPDATACOMBOFD:
23681 {
23682 56174 int32_t pos = (ri->d[rINDEX])/10000;
23683 56174 int32_t val = (value/10000); //flag
23684
1/2
✓ Branch 0 taken 56174 times.
✗ Branch 1 not taken.
56174 if(mapscr *m = GetMapscr(ri->mapsref))
23685 {
23686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56174 times.
56174 if ( ((unsigned) pos) > 175 )
23687 {
23688 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboF[]\n", pos);
23689 }
23690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56174 times.
56174 else if ( ((unsigned) val) >= 256 )
23691 {
23692 Z_scripterrlog("Invalid Flag ID %d used to write to mapdata->ComboF[]\n", val);
23693 }
23694
23695 else
23696 56174 m->sflag[pos]=(val);
23697 56174 }
23698 else
23699 {
23700 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboF[]");
23701 }
23702 }
23703 56174 break;
23704
23705 case MAPDATACOMBOTD:
23706 {
23707 int32_t pos = (ri->d[rINDEX])/10000;
23708 int32_t val = (value/10000); //type
23709 if(mapscr *m = GetMapscr(ri->mapsref))
23710 {
23711 if ( ((unsigned) pos) > 175 )
23712 {
23713 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboT[]\n", pos);
23714 }
23715 else if ( ((unsigned) val) >= cMAX )
23716 {
23717 Z_scripterrlog("Invalid Type ID %d used to write to mapdata->ComboT[]\n", val);
23718 }
23719 else
23720 {
23721 auto cid = m->data[pos];
23722 screen_combo_modify_pre(cid);
23723 combobuf[cid].type=val;
23724 screen_combo_modify_post(cid);
23725 }
23726 }
23727 else
23728 {
23729 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboT[]");
23730 }
23731 }
23732 break;
23733
23734 case MAPDATACOMBOID:
23735 {
23736 int32_t pos = (ri->d[rINDEX])/10000;
23737 int32_t val = (value/10000); //iflag
23738 if(mapscr *m = GetMapscr(ri->mapsref))
23739 {
23740 if ( ((unsigned) pos) > 175 )
23741 {
23742 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboI[]\n", pos);
23743 }
23744 else if ( ((unsigned) val) >= 256 )
23745 {
23746 Z_scripterrlog("Invalid Flag ID %d used to write to mapdata->ComboI[]\n", val);
23747 }
23748
23749 else
23750 combobuf[m->data[pos]].flag=value/10000;
23751 }
23752 else
23753 {
23754 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboI[]");
23755 }
23756 }
23757 break;
23758
23759 case MAPDATACOMBOSD:
23760 {
23761 int32_t pos = (ri->d[rINDEX])/10000;
23762 int32_t val = (value/10000); //solidity
23763 if(mapscr *m = GetMapscr(ri->mapsref))
23764 {
23765 if ( ((unsigned) pos) > 175 )
23766 {
23767 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboS[]\n", pos);
23768 }
23769 else if ( ((unsigned) val) >= 16 )
23770 {
23771 Z_scripterrlog("Invalid Solidity %d used to write to mapdata->ComboS[]\n", val);
23772 }
23773
23774 else
23775 {
23776 combobuf[m->data[pos]].walk &= ~0x0F;
23777 combobuf[m->data[pos]].walk |= (val)&0x0F;
23778 }
23779 }
23780 else
23781 {
23782 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboS[]");
23783 }
23784 }
23785 break;
23786
23787 case MAPDATACOMBOED:
23788 {
23789 int32_t pos = (ri->d[rINDEX])/10000;
23790 int32_t val = (value/10000); //solidity
23791 if(mapscr *m = GetMapscr(ri->mapsref))
23792 {
23793 if ( ((unsigned) pos) > 175 )
23794 {
23795 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboE[]\n", pos);
23796 }
23797 else if ( ((unsigned) val) >= 16 )
23798 {
23799 Z_scripterrlog("Invalid Solidity %d used to write to mapdata->ComboE[]\n", val);
23800 }
23801
23802 else
23803 {
23804 combobuf[m->data[pos]].walk &= ~0xF0;
23805 combobuf[m->data[pos]].walk |= ((val)&0x0F)<<4;
23806 }
23807 }
23808 else
23809 {
23810 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboE[]");
23811 }
23812 }
23813 break;
23814
23815 case MAPDATASCREENSTATED:
23816 {
23817 if(mapscr* m = GetMapscr(ri->mapsref))
23818 {
23819 int32_t mi = get_mi(ri->mapsref);
23820 if(mi<0) break;
23821 (value)?setmapflag(mi, 1<<((ri->d[rINDEX])/10000)) : unsetmapflag(mi, 1 << ((ri->d[rINDEX]) / 10000));
23822 }
23823 else
23824 {
23825 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","State[]");
23826 }
23827 }
23828 break;
23829 case MAPDATAEXSTATED:
23830 {
23831 if(mapscr* m = GetMapscr(ri->mapsref))
23832 {
23833 int32_t mi = get_mi(ri->mapsref);
23834 if(mi<0) break;
23835 (value)?setxmapflag(mi, 1<<((ri->d[rINDEX])/10000)) : unsetxmapflag(mi, 1 << ((ri->d[rINDEX]) / 10000));
23836 }
23837 else
23838 {
23839 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","State[]");
23840 }
23841 break;
23842 }
23843 case MAPDATALENSSHOWS:
23844 {
23845 int ind = ri->d[rINDEX]/10000;
23846 if(ind < 0 || ind > 6)
23847 Z_scripterrlog("Bad index mapdata->LensShows[%d]\n",ind);
23848 else if(mapscr *m = GetMapscr(ri->mapsref))
23849 {
23850 SETFLAG(m->lens_show, 1<<ind, value);
23851 if(value) m->lens_hide &= ~(1<<ind);
23852 }
23853 else Z_scripterrlog("mapdata->LensShows[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
23854 break;
23855 }
23856 case MAPDATALENSHIDES:
23857 {
23858 int ind = ri->d[rINDEX]/10000;
23859 if(ind < 0 || ind > 6)
23860 Z_scripterrlog("Bad index mapdata->LensHides[%d]\n",ind);
23861 else if(mapscr *m = GetMapscr(ri->mapsref))
23862 {
23863 SETFLAG(m->lens_hide, 1<<ind, value);
23864 if(value) m->lens_show &= ~(1<<ind);
23865 }
23866 else Z_scripterrlog("mapdata->LensHides[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
23867 break;
23868 }
23869 case MAPDATASCRDATASIZE:
23870 {
23871 if(mapscr *m = GetMapscr(ri->mapsref))
23872 {
23873 auto mi = get_total_mi(ri->mapsref);
23874 if(mi < 0) break;
23875 game->scriptDataResize(mi, value/10000);
23876 }
23877 else Z_scripterrlog("mapdata->DataSize pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
23878 break;
23879 }
23880 case MAPDATASCRDATA:
23881 {
23882 if(mapscr *m = GetMapscr(ri->mapsref))
23883 {
23884 auto mi = get_total_mi(ri->mapsref);
23885 if(mi < 0) break;
23886 size_t indx = ri->d[rINDEX]/10000;
23887 if(indx >= game->scriptDataSize(mi))
23888 Z_scripterrlog("Invalid index passed to mapdata->Data[]: %d\n", indx);
23889 else game->screen_data[mi][indx] = value;
23890 }
23891 else Z_scripterrlog("mapdata->Data[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
23892 break;
23893 }
23894 case MAPDATAGUYCOUNT:
23895 {
23896 if(mapscr *m = GetMapscr(ri->mapsref))
23897 {
23898 int mi = get_mi(ri->mapsref);
23899 if(mi > -1)
23900 {
23901 game->guys[mi] = vbound(value/10000,10,0);
23902 break;
23903 }
23904 }
23905 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","GuyCount", ri->mapsref);
23906 break;
23907 }
23908
23909 ///----------------------------------------------------------------------------------------------------//
23910 //shopdata sd-> Variables
23911
23912 case SHOPDATAITEM:
23913 {
23914
23915 int32_t ref = ri->shopsref;
23916 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
23917 int32_t indx = ri->d[rINDEX] / 10000;
23918 if ( indx < 0 || indx > 2 )
23919 {
23920 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Item");
23921 break;
23922 }
23923 else
23924 {
23925 if ( isInfo )
23926 {
23927 Z_scripterrlog("Attempted to write an 'item' to an infoshop, using shop ID: %d\n", ri->shopsref);
23928 break;
23929 }
23930 else
23931 {
23932 QMisc.shop[ref].item[indx] = (byte)(vbound((value/10000), 0, 255));
23933 break;
23934 }
23935 }
23936 }
23937 break;
23938 //SET_SHOPDATA_VAR_INDEX(item, "Item", 2); break;
23939 case SHOPDATAHASITEM:
23940 {
23941
23942 int32_t ref = ri->shopsref;
23943 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
23944 int32_t indx = ri->d[rINDEX] / 10000;
23945 if ( indx < 0 || indx > 2 )
23946 {
23947 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "HasItem");
23948 break;
23949 }
23950 else
23951 {
23952 if ( isInfo )
23953 {
23954 Z_scripterrlog("Attempted to write 'hasitem' to an infoshop, using shop ID: %d\n", ri->shopsref);
23955 break;
23956 }
23957 else
23958 {
23959 QMisc.shop[ref].hasitem[indx] = (byte)(vbound((value/10000), 0, 255)); break;
23960 }
23961 }
23962 }
23963 break;
23964 //SET_SHOPDATA_VAR_INDEX(hasitem, "HasItem", 2); break;
23965 case SHOPDATAPRICE:
23966 {
23967
23968 int32_t ref = ri->shopsref;
23969 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
23970 int32_t indx = ri->d[rINDEX] / 10000;
23971 if ( indx < 0 || indx > 2 )
23972 {
23973 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Price");
23974 break;
23975 }
23976 else
23977 {
23978 if ( isInfo )
23979 {
23980 QMisc.info[ref - NUMSHOPS].price[indx] = (word)(vbound((value/10000), 0, 65535));
23981 break;
23982 }
23983 else
23984 {
23985 QMisc.shop[ref].price[indx] = (word)(vbound((value/10000), 0, 65535));
23986 break;
23987 }
23988 }
23989 }
23990 //SET_SHOPDATA_VAR_INDEX(price, "Price", 2); break;
23991 //Pay for info
23992 case SHOPDATASTRING:
23993 {
23994 {
23995 int32_t ref = ri->shopsref;
23996 if ( ref < NUMSHOPS || ref > NUMINFOSHOPS )
23997 {
23998 Z_scripterrlog("Invalid Info Shop ID passed to shopdata->String[]: %d\n", ref);
23999 break;
24000 }
24001 else
24002 {
24003 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
24004 int32_t indx = ri->d[rINDEX] / 10000;
24005 if ( indx < 0 || indx > 2 )
24006 {
24007 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "HasItem");
24008 break;
24009 }
24010 else
24011 {
24012 if ( isInfo )
24013 {
24014 QMisc.info[ref - NUMSHOPS].str[indx] = (word)(vbound((value/10000), 0, 32767));
24015 break;
24016 }
24017 else
24018 {
24019 QMisc.shop[ref].str[indx] = (word)(vbound((value/10000), 0, 32767));
24020 break;
24021 }
24022 }
24023
24024
24025 }
24026
24027 //GET_SHOPDATA_VAR_INDEX(str, String, 2); break;
24028 } break;
24029 }
24030
24031 ///----------------------------------------------------------------------------------------------------//
24032 //dmapdata dmd-> Variables
24033 case DMAPDATAMAP: //byte
24034 {
24035 DMaps[ri->dmapsref].map = ((byte)(value / 10000)) - 1; break;
24036 }
24037 case DMAPDATALEVEL: //word
24038 {
24039 DMaps[ri->dmapsref].level = ((word)(value / 10000)); break;
24040 }
24041 case DMAPDATAOFFSET: //char
24042 {
24043 DMaps[ri->dmapsref].xoff = ((char)(value / 10000)); break;
24044 }
24045 case DMAPDATACOMPASS: //byte
24046 {
24047 DMaps[ri->dmapsref].compass = ((byte)(value / 10000)); break;
24048 }
24049 case DMAPDATAPALETTE: //word
24050 {
24051 DMaps[ri->dmapsref].color= ((word)(value / 10000));
24052 if(ri->dmapsref == currdmap)
24053 {
24054 loadlvlpal(DMaps[ri->dmapsref].color);
24055 currcset = DMaps[ri->dmapsref].color;
24056 }
24057 break;
24058 }
24059 case DMAPDATAMIDI: //byte
24060 {
24061 DMaps[ri->dmapsref].midi = ((byte)((value / 10000)+MIDIOFFSET_DMAP)); break;
24062 }
24063 case DMAPDATACONTINUE: //byte
24064 {
24065 DMaps[ri->dmapsref].cont = ((byte)(value / 10000)); break;
24066 }
24067 case DMAPDATATYPE: //byte
24068 {
24069 DMaps[ri->dmapsref].type = (((byte)(value / 10000))&dmfTYPE) | (DMaps[ri->dmapsref].type&~dmfTYPE); break;
24070 }
24071 case DMAPSCRIPT: //byte
24072 {
24073 FFScript::deallocateAllScriptOwned(ScriptType::DMap, ri->dmapsref);
24074 DMaps[ri->dmapsref].script = vbound((value / 10000),0,NUMSCRIPTSDMAP-1); break;
24075 }
24076 case DMAPDATASIDEVIEW: //byte, treat as bool
24077 {
24078 DMaps[ri->dmapsref].sideview = ((value) ? 1 : 0); break;
24079 }
24080 case DMAPDATAGRID: //byte[8] --array
24081 {
24082 int32_t indx = ri->d[rINDEX] / 10000;
24083 if ( indx < 0 || indx > 7 )
24084 {
24085 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx); break;
24086 }
24087 else
24088 {
24089 DMaps[ri->dmapsref].grid[indx] = ((byte)(value / 10000)); break;
24090 }
24091 }
24092 case DMAPINITD:
24093 {
24094 int32_t indx = ri->d[rINDEX] / 10000;
24095 if ( indx < 0 || indx > 7 )
24096 {
24097 Z_scripterrlog("Invalid index supplied to dmapdata->InitD[]: %d\n", indx); break;
24098 }
24099 else
24100 {
24101 DMaps[ri->dmapsref].initD[indx] = value; break;
24102 }
24103 }
24104 case DMAPDATAMINIMAPTILE: //word - two of these, so let's do MinimapTile[2]
24105 {
24106 int32_t indx = ri->d[rINDEX] / 10000;
24107 switch(indx)
24108 {
24109 case 0: { DMaps[ri->dmapsref].minimap_1_tile = ((word)(value / 10000)); break; }
24110 case 1: { DMaps[ri->dmapsref].minimap_2_tile = ((word)(value / 10000)); break; }
24111 default:
24112 {
24113 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapTile[]: %d\n", indx);
24114 break;
24115 }
24116 }
24117 break;
24118 }
24119 case DMAPDATAMINIMAPCSET: //byte - two of these, so let's do MinimapCSet[2]
24120 {
24121 int32_t indx = ri->d[rINDEX] / 10000;
24122 switch(indx)
24123 {
24124 case 0: { DMaps[ri->dmapsref].minimap_1_cset= ((byte)(value / 10000)); break; }
24125 case 1: { DMaps[ri->dmapsref].minimap_2_cset= ((byte)(value / 10000)); break; }
24126 default:
24127 {
24128 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapCSet[]: %d\n", indx);
24129 break;
24130 }
24131 }
24132 break;
24133 }
24134 case DMAPDATALARGEMAPTILE: //word -- two of these, so let's to LargemapTile[2]
24135 {
24136 int32_t indx = ri->d[rINDEX] / 10000;
24137 switch(indx)
24138 {
24139 case 0: { DMaps[ri->dmapsref].largemap_1_tile = ((word)(value / 10000)); break; }
24140 case 1: { DMaps[ri->dmapsref].largemap_2_tile = ((word)(value / 10000)); break; }
24141 default:
24142 {
24143 Z_scripterrlog("Invalid index supplied to dmapdata->LargeMapTile[]: %d\n", indx);
24144 break;
24145 }
24146 }
24147 break;
24148 }
24149 case DMAPDATALARGEMAPCSET: //word -- two of these, so let's to LargemaCSet[2]
24150 {
24151 int32_t indx = ri->d[rINDEX] / 10000;
24152 switch(indx)
24153 {
24154 case 0: { DMaps[ri->dmapsref].largemap_1_cset= ((byte)(value / 10000)); break; }
24155 case 1: { DMaps[ri->dmapsref].largemap_2_cset= ((byte)(value / 10000)); break; }
24156 default:
24157 {
24158 Z_scripterrlog("Invalid index supplied to dmapdata->LargeMapCSet[]: %d\n", indx);
24159 break;
24160 }
24161 }
24162 break;
24163 }
24164 case DMAPDATAMUISCTRACK: //byte
24165 {
24166 DMaps[ri->dmapsref].tmusictrack= ((byte)(value / 10000)); break;
24167 }
24168 case DMAPDATASUBSCRA:
24169 {
24170 bool changed = DMaps[ri->dmapsref].active_subscreen != ((byte)(value / 10000));
24171 DMaps[ri->dmapsref].active_subscreen= ((byte)(value / 10000));
24172 if(changed&&ri->dmapsref==currdmap)
24173 update_subscreens();
24174 break;
24175 }
24176 case DMAPDATASUBSCRP:
24177 {
24178 bool changed = DMaps[ri->dmapsref].passive_subscreen != ((byte)(value / 10000));
24179 DMaps[ri->dmapsref].passive_subscreen= ((byte)(value / 10000));
24180 if(changed&&ri->dmapsref==currdmap)
24181 update_subscreens();
24182 break;
24183 }
24184 case DMAPDATASUBSCRO:
24185 {
24186 bool changed = DMaps[ri->dmapsref].overlay_subscreen != ((byte)(value / 10000));
24187 DMaps[ri->dmapsref].overlay_subscreen = ((byte)(value / 10000));
24188 if(changed&&ri->dmapsref==currdmap)
24189 update_subscreens();
24190 break;
24191 }
24192 case DMAPDATADISABLEDITEMS: //byte[MAXITEMS]
24193 {
24194 int32_t indx = ri->d[rINDEX] / 10000;
24195 if ( indx < 0 || indx > (MAXITEMS-1) )
24196 {
24197 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx); break;
24198 }
24199 else
24200 {
24201 DMaps[ri->dmapsref].disableditems[indx] = ((byte)(value / 10000)); break;
24202 }
24203 }
24204
24205 case DMAPDATAFLAGARR: //int32_t
24206 {
24207 int32_t indx = ri->d[rINDEX] / 10000;
24208 if ( ((unsigned)indx) > 31 )
24209 {
24210 Z_scripterrlog("Invalid index supplied to dmapdata->Flags[]: %d\n", indx);
24211 break;
24212 }
24213 if ( value ) DMaps[ri->dmapsref].flags |= (1<<indx);
24214 else DMaps[ri->dmapsref].flags &= ~(1<<indx);
24215 break;
24216 }
24217 case DMAPDATAFLAGS: //int32_t
24218 {
24219 DMaps[ri->dmapsref].flags = (value / 10000); break;
24220 }
24221 case DMAPDATAMIRRDMAP:
24222 {
24223 DMaps[ri->dmapsref].mirrorDMap = vbound(value / 10000, -1, MAXDMAPS); break;
24224 }
24225 case DMAPDATALOOPSTART:
24226 {
24227 DMaps[ri->dmapsref].tmusic_loop_start = value;
24228 if (ri->dmapsref == currdmap)
24229 {
24230 if (FFCore.doing_dmap_enh_music(currdmap))
24231 {
24232 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
24233 }
24234 }
24235 break;
24236 }
24237 case DMAPDATALOOPEND:
24238 {
24239 DMaps[ri->dmapsref].tmusic_loop_end = value;
24240 if (ri->dmapsref == currdmap)
24241 {
24242 if (FFCore.doing_dmap_enh_music(currdmap))
24243 {
24244 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
24245 }
24246 }
24247 break;
24248 }
24249 case DMAPDATAXFADEIN:
24250 {
24251 DMaps[ri->dmapsref].tmusic_xfade_in = (value / 10000);
24252 break;
24253 }
24254 case DMAPDATAXFADEOUT:
24255 {
24256 DMaps[ri->dmapsref].tmusic_xfade_out = (value / 10000);
24257 if (DMaps[currdmap].tmusic[0]!=0 && strcmp(DMaps[ri->dmapsref].tmusic, zcmusic->filename) == 0)
24258 {
24259 zcmusic->fadeoutframes = (value / 10000);
24260 }
24261 break;
24262 }
24263 case DMAPDATAINTROSTRINGID:
24264 {
24265 DMaps[ri->dmapsref].intro_string_id = (value / 10000);
24266 break;
24267 }
24268 case MUSICUPDATECOND:
24269 {
24270 FFCore.music_update_cond = vbound(value / 10000, 0, 255);
24271 break;
24272 }
24273 case MUSICUPDATEFLAGS:
24274 {
24275 int32_t indx = ri->d[rINDEX] / 10000;
24276 if (indx < 0 || indx > 1)
24277 {
24278 Z_scripterrlog("Invalid Index passed to Audio->MusicRefreshFlags[]: %d\n", indx);
24279 break;
24280 }
24281 SETFLAG(FFCore.music_update_flags, 1 << indx, value);
24282 break;
24283 }
24284 case DMAPDATAASUBSCRIPT: //byte
24285 {
24286 FFScript::deallocateAllScriptOwned(ScriptType::ScriptedActiveSubscreen, ri->dmapsref);
24287 DMaps[ri->dmapsref].active_sub_script = vbound((value / 10000),0,NUMSCRIPTSDMAP-1); break;
24288 }
24289 case DMAPDATAMAPSCRIPT: //byte
24290 {
24291 3225 FFScript::deallocateAllScriptOwned(ScriptType::OnMap, ri->dmapsref);
24292 3225 DMaps[ri->dmapsref].onmap_script = vbound((value / 10000),0,NUMSCRIPTSDMAP-1); break;
24293 }
24294 case DMAPDATAPSUBSCRIPT: //byte
24295 {
24296 FFScript::deallocateAllScriptOwned(ScriptType::ScriptedPassiveSubscreen, ri->dmapsref);
24297 word val = vbound((value / 10000),0,NUMSCRIPTSDMAP-1);
24298 if (FFCore.doscript(ScriptType::ScriptedPassiveSubscreen) && ri->dmapsref == currdmap && val == DMaps[ri->dmapsref].passive_sub_script)
24299 break;
24300 DMaps[ri->dmapsref].passive_sub_script = val;
24301 if(ri->dmapsref == currdmap)
24302 {
24303 FFCore.doscript(ScriptType::ScriptedPassiveSubscreen) = val != 0;
24304 };
24305 break;
24306 }
24307 case DMAPDATASUBINITD:
24308 {
24309 int32_t indx = ri->d[rINDEX] / 10000;
24310 if ( indx < 0 || indx > 7 )
24311 {
24312 Z_scripterrlog("Invalid index supplied to dmapdata->SubInitD[]: %d\n", indx); break;
24313 }
24314 else
24315 {
24316 DMaps[ri->dmapsref].sub_initD[indx] = value; break;
24317 }
24318 }
24319
24320 case DMAPDATAMAPINITD:
24321 {
24322 int32_t indx = ri->d[rINDEX] / 10000;
24323 if ( indx < 0 || indx > 7 )
24324 {
24325 Z_scripterrlog("Invalid index supplied to dmapdata->MapInitD[]: %d\n", indx); break;
24326 }
24327 else
24328 {
24329 DMaps[ri->dmapsref].onmap_initD[indx] = value; break;
24330 }
24331 }
24332
24333 case DMAPDATACHARTED:
24334 {
24335 int32_t scr = ri->d[rINDEX] / 10000;
24336 if(ri->dmapsref >= MAXDMAPS)
24337 {
24338 Z_scripterrlog("Invalid DMap reference used for dmapdata->Charted[]: %d\n", ri->dmapsref);
24339 }
24340 // else if((DMaps[get_currdmap()].type&dmfTYPE) == dmOVERW)
24341 // {
24342 // Z_scripterrlog("dmapdata->Charted[] cannot presently be used on Overworld-type dmaps\n");
24343 // }
24344 else if(((unsigned)(scr)) > 127)
24345 {
24346 Z_scripterrlog("Invalid index supplied to dmapdata->Charted[]: %d\n", scr);
24347 }
24348 else
24349 {
24350 int32_t col = (scr&15)-(DMaps[ri->dmapsref].type==dmOVERW ? 0 : DMaps[ri->dmapsref].xoff);
24351 if((DMaps[ri->dmapsref].type&dmfTYPE)!=dmOVERW ? (((unsigned)col) > 7) : (((unsigned)col) > 15))
24352 break; //Out-of-bounds; don't attempt write!
24353 int32_t di = (ri->dmapsref << 7) + (scr & 0x7F);
24354 game->bmaps[di] = (value/10000)&0x8F;
24355 }
24356 break;
24357 }
24358 //case DMAPDATAGRAVITY: //unimplemented
24359 //case DMAPDATAJUMPLAYER: //unimplemented
24360
24361 ///----------------------------------------------------------------------------------------------------//
24362 //messagedata msgd-> Variables
24363
24364
24365 case MESSAGEDATANEXT: //W
24366 {
24367 int32_t ID = ri->zmsgref;
24368
24369 if(BC::checkMessage(ID, "messagedata->Next") != SH::_NoError)
24370 break;
24371 else
24372 MsgStrings[ID].nextstring = vbound((value/10000), 0, (msg_count-1));
24373 break;
24374 }
24375
24376 case MESSAGEDATATILE: //W
24377 {
24378 int32_t ID = ri->zmsgref;
24379
24380 if(BC::checkMessage(ID, "messagedata->Tile") != SH::_NoError)
24381 break;
24382 else
24383 MsgStrings[ID].tile = vbound((value/10000), 0, (NEWMAXTILES));
24384 break;
24385 }
24386
24387 case MESSAGEDATACSET: //b
24388 {
24389 int32_t ID = ri->zmsgref;
24390
24391 if(BC::checkMessage(ID, "messagedata->CSet") != SH::_NoError)
24392 break;
24393 else
24394 MsgStrings[ID].cset = ((byte)vbound((value/10000), 0, 15));
24395 break;
24396 }
24397 case MESSAGEDATATRANS: //BOOL
24398 {
24399 int32_t ID = ri->zmsgref;
24400
24401 if(BC::checkMessage(ID, "messagedata->Transparent") != SH::_NoError)
24402 break;
24403 else
24404 (MsgStrings[ID].trans) = ((value)?true:false);
24405 break;
24406 }
24407 case MESSAGEDATAFONT: //B
24408 {
24409 int32_t ID = ri->zmsgref;
24410
24411 if(BC::checkMessage(ID, "messagedata->Font") != SH::_NoError)
24412 break;
24413 else
24414 MsgStrings[ID].font = ((byte)vbound((value/10000), 0, 255));
24415 break;
24416 }
24417 case MESSAGEDATAX: //SHORT
24418 {
24419 int32_t ID = ri->zmsgref;
24420
24421 if(BC::checkMessage(ID, "messagedata->X") != SH::_NoError)
24422 break;
24423 else
24424 MsgStrings[ID].x = ((int16_t)vbound((value/10000), SHRT_MIN, SHRT_MAX));
24425 break;
24426 }
24427 case MESSAGEDATAY: //SHORT
24428 {
24429 int32_t ID = ri->zmsgref;
24430
24431 if(BC::checkMessage(ID, "messagedata->Y") != SH::_NoError)
24432 break;
24433 else
24434 MsgStrings[ID].y = ((int16_t)vbound((value/10000), SHRT_MIN, SHRT_MAX));
24435 break;
24436 }
24437 case MESSAGEDATAW: //UNSIGNED SHORT
24438 {
24439 int32_t ID = ri->zmsgref;
24440
24441 if(BC::checkMessage(ID, "messagedata->Width") != SH::_NoError)
24442 break;
24443 else
24444 MsgStrings[ID].w = ((uint16_t)vbound((value/10000), 0, USHRT_MAX));
24445 break;
24446 }
24447 case MESSAGEDATAH: //UNSIGNED SHORT
24448 {
24449 int32_t ID = ri->zmsgref;
24450
24451 if(BC::checkMessage(ID, "messagedata->Height") != SH::_NoError)
24452 break;
24453 else
24454 MsgStrings[ID].h = ((uint16_t)vbound((value/10000), 0, USHRT_MAX));
24455 break;
24456 }
24457 case MESSAGEDATASFX: //BYTE
24458 {
24459 int32_t ID = ri->zmsgref;
24460
24461 if(BC::checkMessage(ID, "messagedata->Sound") != SH::_NoError)
24462 break;
24463 else
24464 MsgStrings[ID].sfx = ((byte)vbound((value/10000), 0, 255));
24465 break;
24466 }
24467 case MESSAGEDATALISTPOS: //WORD
24468 {
24469 int32_t ID = ri->zmsgref;
24470
24471 if(BC::checkMessage(ID, "messagedata->ListPosition") != SH::_NoError)
24472 break;
24473 else
24474 MsgStrings[ID].listpos = vbound((value/10000), 1, (msg_count-1));
24475 break;
24476 }
24477 case MESSAGEDATAVSPACE: //BYTE
24478 {
24479 int32_t ID = ri->zmsgref;
24480
24481 if(BC::checkMessage(ID, "messagedata->VSpace") != SH::_NoError)
24482 break;
24483 else
24484 MsgStrings[ID].vspace = ((byte)vbound((value/10000), 0, 255));
24485 break;
24486 }
24487 case MESSAGEDATAHSPACE: //BYTE
24488 {
24489 int32_t ID = ri->zmsgref;
24490
24491 if(BC::checkMessage(ID, "messagedata->HSpace") != SH::_NoError)
24492 break;
24493 else
24494 MsgStrings[ID].hspace = ((byte)vbound((value/10000), 0, 255));
24495 break;
24496 }
24497 case MESSAGEDATAFLAGS: //BYTE
24498 {
24499 int32_t ID = ri->zmsgref;
24500
24501 if(BC::checkMessage(ID, "messagedata->Flags") != SH::_NoError)
24502 break;
24503 else
24504 MsgStrings[ID].stringflags = ((byte)vbound((value/10000), 0, 255));
24505 break;
24506 }
24507 case MESSAGEDATAMARGINS: //BYTE, 4
24508 {
24509 int32_t indx = ri->d[rINDEX] / 10000;
24510 if ( indx < 0 || indx > 3 )
24511 {
24512 Z_scripterrlog("Invalid index supplied to messagedata->Margins[]: %d\n", indx);
24513 break;
24514 }
24515 int32_t ID = ri->zmsgref;
24516
24517 if(BC::checkMessage(ID, "messagedata->Margins[]") != SH::_NoError)
24518 break;
24519 else
24520 MsgStrings[ID].margins[indx] = ((byte)vbound((value/10000), 0, 255));
24521 break;
24522 }
24523 case MESSAGEDATAPORTTILE: //INT
24524 {
24525 int32_t ID = ri->zmsgref;
24526
24527 if(BC::checkMessage(ID, "messagedata->PortraitTile") != SH::_NoError)
24528 break;
24529 else
24530 MsgStrings[ID].portrait_tile = vbound((value/10000), 0, (NEWMAXTILES));
24531 break;
24532 }
24533 case MESSAGEDATAPORTCSET: //BYTE
24534 {
24535 int32_t ID = ri->zmsgref;
24536
24537 if(BC::checkMessage(ID, "messagedata->PortraitCSet") != SH::_NoError)
24538 break;
24539 else
24540 MsgStrings[ID].portrait_cset = ((byte)vbound((value/10000), 0, 15));
24541 break;
24542 }
24543 case MESSAGEDATAPORTX: //BYTE
24544 {
24545 int32_t ID = ri->zmsgref;
24546
24547 if(BC::checkMessage(ID, "messagedata->PortraitX") != SH::_NoError)
24548 break;
24549 else
24550 MsgStrings[ID].portrait_x = ((byte)vbound((value/10000), 0, 255));
24551 break;
24552 }
24553 case MESSAGEDATAPORTY: //BYTE
24554 {
24555 int32_t ID = ri->zmsgref;
24556
24557 if(BC::checkMessage(ID, "messagedata->PortraitY") != SH::_NoError)
24558 break;
24559 else
24560 MsgStrings[ID].portrait_y = ((byte)vbound((value/10000), 0, 255));
24561 break;
24562 }
24563 case MESSAGEDATAPORTWID: //BYTE
24564 {
24565 int32_t ID = ri->zmsgref;
24566
24567 if(BC::checkMessage(ID, "messagedata->PortraitTileWidth") != SH::_NoError)
24568 break;
24569 else
24570 MsgStrings[ID].portrait_tw = ((byte)vbound((value/10000), 0, 16));
24571 break;
24572 }
24573 case MESSAGEDATAPORTHEI: //BYTE
24574 {
24575 int32_t ID = ri->zmsgref;
24576
24577 if(BC::checkMessage(ID, "messagedata->PortraitTileHeight") != SH::_NoError)
24578 break;
24579 else
24580 MsgStrings[ID].portrait_th = ((byte)vbound((value/10000), 0, 14));
24581 break;
24582 }
24583 case MESSAGEDATAFLAGSARR: //BOOL, 7
24584 {
24585 int32_t indx = ri->d[rINDEX] / 10000;
24586 int32_t ID = ri->zmsgref;
24587
24588 if(BC::checkMessage(ID, "messagedata->Flags[]") != SH::_NoError)
24589 break;
24590 else
24591 {
24592 switch(indx)
24593 {
24594 case 0:
24595 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_WRAP : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_WRAP;
24596 break;
24597 case 1:
24598 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_CONT : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_CONT;
24599 break;
24600 case 2: //Not implemented
24601 //(value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_CENTER : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_CENTER;
24602 break;
24603 case 3: //Not implemented
24604 //(value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_RIGHT : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_RIGHT;
24605 break;
24606 case 4:
24607 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_FULLTILE : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_FULLTILE;
24608 break;
24609 case 5:
24610 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_TRANS_BG : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_TRANS_BG;
24611 break;
24612 case 6:
24613 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_TRANS_FG : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_TRANS_FG;
24614 break;
24615 default:
24616 Z_scripterrlog("Invalid index supplied to messagedata->Flags[]: %d\n", indx);
24617 break;
24618 }
24619 }
24620 break;
24621 }
24622
24623
24624
24625
24626 ///----------------------------------------------------------------------------------------------------//
24627 //combodata cd-> Setter Variables
24628 //newcombo
24629 #define SET_COMBO_VAR_INT(member, str) \
24630 { \
24631 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24632 { \
24633 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24634 } \
24635 else \
24636 { \
24637 combobuf[ri->combosref].member = vbound((value / 10000),0,214747); \
24638 } \
24639 } \
24640
24641 #define SET_COMBO_VAR_DWORD(member, str) \
24642 { \
24643 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24644 { \
24645 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24646 } \
24647 else \
24648 { \
24649 combobuf[ri->combosref].member = vbound((value / 10000),0,32767); \
24650 } \
24651 } \
24652
24653 #define SET_COMBO_VAR_BYTE(member, str) \
24654 { \
24655 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24656 { \
24657 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24658 } \
24659 else \
24660 { \
24661 combobuf[ri->combosref].member = vbound((value / 10000),0,255); \
24662 } \
24663 } \
24664
24665 #define SET_COMBO_VAR_INDEX(member, str, indexbound) \
24666 { \
24667 int32_t indx = ri->d[rINDEX] / 10000; \
24668 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24669 { \
24670 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24671 } \
24672 else if ( indx < 0 || indx >= indexbound ) \
24673 { \
24674 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
24675 } \
24676 else \
24677 { \
24678 combobuf[ri->combosref].member[indx] = vbound((value / 10000),0,214747); \
24679 } \
24680 }
24681
24682 #define SET_COMBO_VAR_INDEX2(member, str, indexbound, low, high) \
24683 { \
24684 int32_t indx = ri->d[rINDEX] / 10000; \
24685 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24686 { \
24687 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24688 } \
24689 else if ( indx < 0 || indx >= indexbound ) \
24690 { \
24691 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
24692 } \
24693 else \
24694 { \
24695 combobuf[ri->combosref].member[indx] = vbound((value / 10000),low,high); \
24696 } \
24697 }
24698
24699 #define SET_COMBO_BYTE_INDEX(member, str, indexbound) \
24700 { \
24701 int32_t indx = ri->d[rINDEX] / 10000; \
24702 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24703 { \
24704 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24705 } \
24706 else if ( indx < 0 || indx >= indexbound ) \
24707 { \
24708 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
24709 } \
24710 else \
24711 { \
24712 combobuf[ri->combosref].member[indx] = vbound((value / 10000),0,255); \
24713 } \
24714 }
24715
24716 #define SET_COMBO_FLAG(member, str) \
24717 { \
24718 int32_t flag = (value/10000); \
24719 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24720 { \
24721 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24722 } \
24723 else \
24724 { \
24725 if ( flag != 0 ) \
24726 { \
24727 combobuf[ri->combosref].member|=flag; \
24728 } \
24729 else combobuf[ri->combosref].member|= ~flag; \
24730 } \
24731 } \
24732
24733 //comboclass
24734 #define SET_COMBOCLASS_VAR_INT(member, str) \
24735 { \
24736 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24737 { \
24738 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24739 } \
24740 else \
24741 { \
24742 combo_class_buf[combobuf[ri->combosref].type].member = vbound((value / 10000),0,214747); \
24743 } \
24744 } \
24745
24746 #define SET_COMBOCLASS_VAR_DWORD(member, str) \
24747 { \
24748 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24749 { \
24750 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24751 } \
24752 else \
24753 { \
24754 combo_class_buf[combobuf[ri->combosref].type].member = vbound((value / 10000),0,32767); \
24755 } \
24756 } \
24757
24758 #define SET_COMBOCLASS_VAR_BYTE(member, str) \
24759 { \
24760 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24761 { \
24762 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24763 } \
24764 else \
24765 { \
24766 combo_class_buf[combobuf[ri->combosref].type].member = vbound((value / 10000),0,255); \
24767 } \
24768 } \
24769
24770 #define SET_COMBOCLASS_VAR_INDEX(member, str, indexbound) \
24771 { \
24772 int32_t indx = ri->d[rINDEX] / 10000; \
24773 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24774 { \
24775 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24776 } \
24777 else if ( indx < 0 || indx > indexbound ) \
24778 { \
24779 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
24780 } \
24781 else \
24782 { \
24783 combo_class_buf[combobuf[ri->combosref].type].member[indx] = vbound((value / 10000),0,214747); \
24784 } \
24785 }
24786
24787 #define SET_COMBOCLASS_BYTE_INDEX(member, str, indexbound) \
24788 { \
24789 int32_t indx = ri->d[rINDEX] / 10000; \
24790 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24791 { \
24792 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24793 } \
24794 else if ( indx < 0 || indx > indexbound ) \
24795 { \
24796 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
24797 } \
24798 else \
24799 { \
24800 combo_class_buf[combobuf[ri->combosref].type].member[indx] = vbound((value / 10000),0,255); \
24801 } \
24802 }
24803
24804 #define SET_COMBOCLASS_FLAG(member, str) \
24805 { \
24806 int32_t flag = (value/10000); \
24807 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24808 { \
24809 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24810 } \
24811 else \
24812 { \
24813 if ( flag != 0 ) \
24814 { \
24815 combo_class_buf[combobuf[ri->combosref].type].member|=flag; \
24816 } \
24817 else combo_class_buf[combobuf[ri->combosref].type].member|= ~flag; \
24818 } \
24819 } \
24820
24821 //NEWCOMBO STRUCT
24822 case COMBODTILE: SET_COMBO_VAR_INT(tile, "Tile"); break; //word
24823 case COMBODOTILE:
24824 {
24825 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24826 {
24827 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "OriginalTile");
24828 }
24829 else
24830 {
24831 newcombo& cdata = combobuf[ri->combosref];
24832 cdata.o_tile = vbound((value / 10000),0,NEWMAXTILES);
24833 if(get_qr(qr_NEW_COMBO_ANIMATION))
24834 {
24835 cdata.tile = cdata.o_tile + ((1+cdata.skipanim)*cdata.cur_frame);
24836 if(int32_t rowoffset = TILEROW(cdata.tile)-TILEROW(cdata.o_tile))
24837 {
24838 cdata.tile += cdata.skipanimy * rowoffset * TILES_PER_ROW;
24839 }
24840 }
24841 }
24842 break;
24843 }
24844 case COMBODFRAME: SET_COMBO_VAR_BYTE(cur_frame, "Frame"); break; //char
24845 case COMBODACLK: SET_COMBO_VAR_BYTE(aclk, "AClk"); break; //char
24846 case COMBODATASCRIPT: SET_COMBO_VAR_DWORD(script, "Script"); break; //word
24847 case COMBODASPEED: SET_COMBO_VAR_BYTE(speed, "ASpeed"); break; //char
24848 case COMBODFLIP: SET_COMBO_VAR_BYTE(flip, "Flip"); break; //char
24849 case COMBODWALK:
24850 {
24851 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24852 {
24853 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Walk");
24854 }
24855 else
24856 {
24857 combobuf[ri->combosref].walk &= ~0x0F;
24858 combobuf[ri->combosref].walk |= (value / 10000)&0x0F;
24859 }
24860 break;
24861 }
24862 case COMBODEFFECT:
24863 {
24864 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24865 {
24866 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Effect");
24867 }
24868 else
24869 {
24870 combobuf[ri->combosref].walk &= ~0xF0;
24871 combobuf[ri->combosref].walk |= ((value / 10000)&0x0F)<<4;
24872 }
24873 break;
24874 }
24875 case COMBODTYPE:
24876 {
24877 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24878 {
24879 Z_scripterrlog("Invalid Combo ID passed to combodata->Type: %d\n", (ri->combosref*10000));
24880 }
24881 else
24882 {
24883 screen_combo_modify_pre(ri->combosref);
24884 combobuf[ri->combosref].type = vbound((value / 10000),0,255);
24885 screen_combo_modify_post(ri->combosref);
24886 }
24887 break;
24888 }
24889 case COMBODCSET:
24890 {
24891 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24892 {
24893 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2");
24894 }
24895 else
24896 {
24897 int8_t v = vbound(value, -8, 7);
24898 combobuf[ri->combosref].csets &= ~0xF;
24899 combobuf[ri->combosref].csets |= v;
24900 }
24901 break;
24902 }
24903 case COMBODCSET2FLAGS:
24904 {
24905 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24906 {
24907 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2Flags");
24908 }
24909 else
24910 {
24911 combobuf[ri->combosref].csets &= 0xF;
24912 combobuf[ri->combosref].csets |= (value&0xF)<<4;
24913 }
24914 break;
24915 }
24916 case COMBODFOO: break; //W
24917 case COMBODFRAMES: SET_COMBO_VAR_BYTE(frames, "Frames"); break; //C
24918 case COMBODNEXTD: SET_COMBO_VAR_DWORD(speed, "NextData"); break; //W
24919 case COMBODNEXTC: SET_COMBO_VAR_BYTE(nextcombo, "NextCSet"); break; //C
24920 case COMBODFLAG: SET_COMBO_VAR_BYTE(nextcset, "Flag"); break; //C
24921 case COMBODSKIPANIM: SET_COMBO_VAR_BYTE(skipanim, "SkipAnim"); break; //C
24922 case COMBODNEXTTIMER: SET_COMBO_VAR_DWORD(nexttimer, "NextTimer"); break; //W
24923 case COMBODAKIMANIMY: SET_COMBO_VAR_BYTE(skipanimy, "SkipAnimY"); break; //C
24924 case COMBODANIMFLAGS: SET_COMBO_VAR_BYTE(animflags, "AnimFlags"); break; //C
24925 case COMBODEXPANSION: SET_COMBO_BYTE_INDEX(expansion, "Expansion[]", 6); break; //C , 6 INDICES
24926 case COMBODATTRIBUTES:
24927 {
24928 int32_t indx = ri->d[rINDEX] / 10000;
24929 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24930 {
24931 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Attributes[]");
24932 }
24933 else if ( indx < 0 || indx > 4 )
24934 {
24935 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "Attributes[]");
24936 }
24937 else
24938 {
24939 combobuf[ri->combosref].attributes[indx] = value;
24940 }
24941 }break;
24942 //case COMBODATAINITD: SET_COMBO_VAR_INDEX(initd, "InitD[]", 2); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
24943 case COMBODATAINITD:
24944 {
24945 int32_t indx = ri->d[rINDEX] / 10000;
24946 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24947 {
24948 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "InitD[]");
24949 }
24950 else if ( ((unsigned)indx) > 8 )
24951 {
24952 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "InitD[]");
24953 }
24954 else
24955 {
24956 combobuf[ri->combosref].initd[indx] = (value * ( get_qr(qr_COMBODATA_INITD_MULT_TENK) ? 10000 : 1));
24957 }
24958 break;
24959 }
24960
24961
24962 case COMBODATTRIBYTES: SET_COMBO_VAR_INDEX(attribytes, "Attribytes[]", 8); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
24963 case COMBODATTRISHORTS: SET_COMBO_VAR_INDEX2(attrishorts, "Attrishorts[]", 8, -32768, 32767); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
24964 case COMBODUSRFLAGARR:
24965 {
24966 int32_t indx = ri->d[rINDEX] / 10000;
24967 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
24968 {
24969 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "Flags[]", (ri->combosref * 10000));
24970 }
24971 else if (((unsigned)indx) > 15)
24972 {
24973 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "Flags[]", indx);
24974 }
24975 else
24976 {
24977 SETFLAG(combobuf[ri->combosref].usrflags, 1 << indx, value);
24978 }
24979 break;
24980 }
24981 case COMBODGENFLAGARR:
24982 {
24983 int32_t indx = ri->d[rINDEX] / 10000;
24984 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
24985 {
24986 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "GenFlags[]", (ri->combosref * 10000));
24987 }
24988 else if (((unsigned)indx) > 0)
24989 {
24990 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "GenFlags[]", indx);
24991 }
24992 else
24993 {
24994 SETFLAG(combobuf[ri->combosref].genflags, 1 << indx, value);
24995 }
24996 break;
24997 }
24998 case COMBODUSRFLAGS: SET_COMBO_VAR_INT(usrflags, "UserFlags"); break; //LONG
24999 case COMBODTRIGGERFLAGS: SET_COMBO_VAR_INDEX(triggerflags, "TriggerFlags[]", 6); break; //LONG 3 INDICES AS FLAGSETS
25000 case COMBODTRIGGERFLAGS2:
25001 {
25002 int32_t indx = ri->d[rINDEX] / 10000;
25003 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25004 {
25005 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TrigFlags[]");
25006 }
25007 else if ( unsigned(indx) >= 32*6 )
25008 {
25009 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TrigFlags[]");
25010 }
25011 else
25012 {
25013 SETFLAG(combobuf[ri->combosref].triggerflags[indx/32],1<<(indx%32),value);
25014 }
25015 break;
25016 }
25017 case COMBODTRIGGERBUTTON:
25018 {
25019 int32_t indx = ri->d[rINDEX] / 10000;
25020 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25021 {
25022 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerButton[]");
25023 }
25024 else if ( unsigned(indx) >= 8 )
25025 {
25026 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TriggerButton[]");
25027 }
25028 else
25029 {
25030 SETFLAG(combobuf[ri->combosref].triggerbtn,1<<indx,value);
25031 }
25032 break;
25033 }
25034 case COMBODTRIGGERITEM:
25035 {
25036 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25037 {
25038 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerItem");
25039 }
25040 else combobuf[ri->combosref].triggeritem = vbound(value/10000,0,255);
25041 break;
25042 }
25043 case COMBODTRIGGERTIMER:
25044 {
25045 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25046 {
25047 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerTimer");
25048 }
25049 else combobuf[ri->combosref].trigtimer = vbound(value/10000,0,255);
25050 break;
25051 }
25052 case COMBODTRIGGERSFX:
25053 {
25054 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25055 {
25056 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerSFX");
25057 }
25058 else combobuf[ri->combosref].trigsfx = vbound(value/10000,0,255);
25059 break;
25060 }
25061 case COMBODTRIGGERCHANGECMB:
25062 {
25063 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25064 {
25065 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerChange");
25066 }
25067 else combobuf[ri->combosref].trigchange = vbound(value/10000,-65535,65535);
25068 break;
25069 }
25070 case COMBODTRIGGERPROX:
25071 {
25072 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25073 {
25074 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerProximity");
25075 }
25076 else combobuf[ri->combosref].trigprox = vbound(value/10000,0,65535);
25077 break;
25078 }
25079 case COMBODTRIGGERLIGHTBEAM:
25080 {
25081 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25082 {
25083 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerLightBeam");
25084 }
25085 else combobuf[ri->combosref].triglbeam = vbound(value/10000,0,32);
25086 break;
25087 }
25088 case COMBODTRIGGERCTR:
25089 {
25090 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25091 {
25092 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCounter");
25093 }
25094 else combobuf[ri->combosref].trigctr = vbound(value/10000, 0, MAX_COUNTERS-1);
25095 break;
25096 }
25097 case COMBODTRIGGERCTRAMNT:
25098 {
25099 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25100 {
25101 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCtrAmount");
25102 }
25103 else combobuf[ri->combosref].trigctramnt = vbound(value/10000, -65535, 65535);
25104 break;
25105 }
25106
25107 case COMBODTRIGGERCOOLDOWN:
25108 {
25109 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25110 {
25111 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCooldown: %d\n", (ri->combosref*10000));
25112 }
25113 else combobuf[ri->combosref].trigcooldown = vbound(value/10000, 0, 255);
25114 break;
25115 }
25116 case COMBODTRIGGERCOPYCAT:
25117 {
25118 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25119 {
25120 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCopycat: %d\n", (ri->combosref*10000));
25121 }
25122 else combobuf[ri->combosref].trigcopycat = vbound(value/10000, 0, 255);
25123 break;
25124 }
25125 case COMBODTRIGITEMPICKUP:
25126 {
25127 const int32_t allowed_pflags = ipHOLDUP | ipTIMER | ipSECRETS | ipCANGRAB;
25128 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25129 {
25130 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerSpawnItemPickup: %d\n", (ri->combosref*10000));
25131 }
25132 else combobuf[ri->combosref].spawnip = (value/10000)&allowed_pflags;
25133 break;
25134 }
25135 case COMBODTRIGEXSTATE:
25136 {
25137 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25138 {
25139 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigExState: %d\n", (ri->combosref*10000));
25140 }
25141 else combobuf[ri->combosref].exstate = vbound(value/10000, -1, 31);
25142 break;
25143 }
25144 case COMBODTRIGSPAWNENEMY:
25145 {
25146 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25147 {
25148 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnEnemy: %d\n", (ri->combosref*10000));
25149 }
25150 else combobuf[ri->combosref].spawnenemy = vbound(value/10000, 0, 511);
25151 break;
25152 }
25153 case COMBODTRIGSPAWNITEM:
25154 {
25155 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25156 {
25157 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnItem: %d\n", (ri->combosref*10000));
25158 }
25159 else combobuf[ri->combosref].spawnitem = vbound(value/10000, -255, 255);
25160 break;
25161 }
25162 case COMBODTRIGCSETCHANGE:
25163 {
25164 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25165 {
25166 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigCSetChange: %d\n", (ri->combosref*10000));
25167 }
25168 else combobuf[ri->combosref].trigcschange = vbound(value/10000, -15, 15);
25169 break;
25170 }
25171 case COMBODLIFTGFXCOMBO:
25172 {
25173 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25174 {
25175 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCombo: %d\n", (ri->combosref*10000));
25176 }
25177 else combobuf[ri->combosref].liftcmb = vbound(value/10000, 0, MAXCOMBOS);
25178 break;
25179 }
25180 case COMBODLIFTGFXCCSET:
25181 {
25182 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25183 {
25184 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCSet: %d\n", (ri->combosref*10000));
25185 }
25186 else combobuf[ri->combosref].liftcs = vbound(value/10000, 0, 13);
25187 break;
25188 }
25189 case COMBODLIFTUNDERCMB:
25190 {
25191 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25192 {
25193 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCombo: %d\n", (ri->combosref*10000));
25194 }
25195 else combobuf[ri->combosref].liftundercmb = vbound(value/10000, 0, MAXCOMBOS);
25196 break;
25197 }
25198 case COMBODLIFTUNDERCS:
25199 {
25200 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25201 {
25202 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCSet: %d\n", (ri->combosref*10000));
25203 }
25204 else combobuf[ri->combosref].liftundercs = vbound(value/10000, 0, 13);
25205 break;
25206 }
25207 case COMBODLIFTDAMAGE:
25208 {
25209 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25210 {
25211 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftDamage: %d\n", (ri->combosref*10000));
25212 }
25213 else combobuf[ri->combosref].liftdmg = vbound(value/10000, 0, 255);
25214 break;
25215 }
25216 case COMBODLIFTLEVEL:
25217 {
25218 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25219 {
25220 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftLevel: %d\n", (ri->combosref*10000));
25221 }
25222 else combobuf[ri->combosref].liftlvl = vbound(value/10000, 0, 255);
25223 break;
25224 }
25225 case COMBODLIFTITEM:
25226 {
25227 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25228 {
25229 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftItem: %d\n", (ri->combosref*10000));
25230 }
25231 else combobuf[ri->combosref].liftitm = vbound(value/10000, 0, 255);
25232 break;
25233 }
25234 case COMBODLIFTFLAGS:
25235 {
25236 int32_t indx = ri->d[rINDEX] / 10000;
25237 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25238 {
25239 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftFlags[]: %d\n", (ri->combosref*10000));
25240 break;
25241 }
25242 if ( unsigned(indx) > 7 )
25243 {
25244 Z_scripterrlog("Invalid index supplied to combodata->LiftFlags[]: %d\n", indx);
25245 break;
25246 }
25247 SETFLAG(combobuf[ri->combosref].liftflags, (1<<indx), value);
25248 break;
25249 }
25250 case COMBODLIFTGFXTYPE:
25251 {
25252 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25253 {
25254 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXType: %d\n", (ri->combosref*10000));
25255 }
25256 else combobuf[ri->combosref].liftgfx = vbound(value/10000, 0, 2);
25257 break;
25258 }
25259 case COMBODLIFTGFXSPRITE:
25260 {
25261 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25262 {
25263 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXSprite: %d\n", (ri->combosref*10000));
25264 }
25265 else combobuf[ri->combosref].liftsprite = vbound(value/10000, 0, 255);
25266 break;
25267 }
25268 case COMBODLIFTSFX:
25269 {
25270 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25271 {
25272 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftSFX: %d\n", (ri->combosref*10000));
25273 }
25274 else combobuf[ri->combosref].liftsfx = vbound(value/10000, 0, 255);
25275 break;
25276 }
25277 case COMBODLIFTBREAKSPRITE:
25278 {
25279 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25280 {
25281 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSprite: %d\n", (ri->combosref*10000));
25282 }
25283 else combobuf[ri->combosref].liftbreaksprite = vbound(value/10000, -4, 255);
25284 break;
25285 }
25286 case COMBODLIFTBREAKSFX:
25287 {
25288 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25289 {
25290 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSFX: %d\n", (ri->combosref*10000));
25291 }
25292 else combobuf[ri->combosref].liftbreaksfx = vbound(value/10000, 0, 255);
25293 break;
25294 }
25295 case COMBODLIFTHEIGHT:
25296 {
25297 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25298 {
25299 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftHeight: %d\n", (ri->combosref*10000));
25300 }
25301 else combobuf[ri->combosref].lifthei = vbound(value/10000, 0, 255);
25302 break;
25303 }
25304 case COMBODLIFTTIME:
25305 {
25306 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25307 {
25308 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftTime: %d\n", (ri->combosref*10000));
25309 }
25310 else combobuf[ri->combosref].lifttime = vbound(value/10000, 0, 255);
25311 break;
25312 }
25313 case COMBODLIFTWEAPONITEM:
25314 {
25315 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25316 {
25317 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftWeaponItem: %d\n", (ri->combosref*10000));
25318 }
25319 else combobuf[ri->combosref].lift_parent_item = vbound(value/10000, 0, 255);
25320 break;
25321 }
25322 case COMBODTRIGGERLSTATE:
25323 {
25324 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25325 {
25326 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigLevelState: %d\n", (ri->combosref*10000));
25327 }
25328 else combobuf[ri->combosref].trig_lstate = vbound(value/10000, 0, 31);
25329 break;
25330 }
25331 case COMBODTRIGGERGSTATE:
25332 {
25333 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25334 {
25335 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGlobalState: %d\n", (ri->combosref*10000));
25336 }
25337 else combobuf[ri->combosref].trig_gstate = vbound(value/10000, 0, 255);
25338 break;
25339 }
25340 case COMBODTRIGGERGROUP:
25341 {
25342 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25343 {
25344 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroup: %d\n", (ri->combosref*10000));
25345 }
25346 else combobuf[ri->combosref].trig_group = vbound(value/10000, 0, 255);
25347 break;
25348 }
25349 case COMBODTRIGGERGROUPVAL:
25350 {
25351 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25352 {
25353 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroupVal: %d\n", (ri->combosref*10000));
25354 }
25355 else combobuf[ri->combosref].trig_group_val = vbound(value/10000, 0, 65535);
25356 break;
25357 }
25358 case COMBODTRIGGERGTIMER:
25359 {
25360 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25361 {
25362 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGStateTimer: %d\n", (ri->combosref*10000));
25363 }
25364 else combobuf[ri->combosref].trig_statetime = vbound(value/10000, 0, 214748);
25365 break;
25366 }
25367 case COMBODTRIGGERGENSCRIPT:
25368 {
25369 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25370 {
25371 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGenScript: %d\n", (ri->combosref*10000));
25372 }
25373 else combobuf[ri->combosref].trig_genscr = vbound(value/10000, 0, 65535);
25374 break;
25375 }
25376 case COMBODTRIGGERLEVEL: SET_COMBO_VAR_INT(triggerlevel, "TriggerLevel"); break; //LONG
25377
25378
25379
25380
25381
25382 //COMBOCLASS STRUCT
25383 //case COMBODNAME: //CHAR[64], STRING
25384 case COMBODBLOCKNPC: SET_COMBOCLASS_VAR_BYTE(block_enemies, "BlockNPC"); break; //C
25385 case COMBODBLOCKHOLE: SET_COMBOCLASS_VAR_BYTE(block_hole, "BlockHole"); break; //C
25386 case COMBODBLOCKTRIG: SET_COMBOCLASS_VAR_BYTE(block_trigger, "BlockTrigger"); break; //C
25387 case COMBODBLOCKWEAPON: SET_COMBOCLASS_BYTE_INDEX(block_weapon, "BlockWeapon[]", 32); break; //C, 32 INDICES
25388 case COMBODCONVXSPEED: SET_COMBOCLASS_VAR_DWORD(conveyor_x_speed, "ConveyorSpeedX"); break; //SHORT
25389 case COMBODCONVYSPEED: SET_COMBOCLASS_VAR_DWORD(conveyor_y_speed, "ConveyorSpeedY"); break; //SHORT
25390 case COMBODSPAWNNPC: SET_COMBOCLASS_VAR_DWORD(create_enemy, "SpawnNPC"); break; //W
25391 case COMBODSPAWNNPCWHEN: SET_COMBOCLASS_VAR_BYTE(create_enemy_when, "SpawnNPCWhen"); break; //C
25392 case COMBODSPAWNNPCCHANGE: SET_COMBOCLASS_VAR_INT(create_enemy_change, "SpawnNPCChange"); break; //LONG
25393 case COMBODDIRCHANGETYPE: SET_COMBOCLASS_VAR_BYTE(directional_change_type, "DirChange"); break; //C
25394 case COMBODDISTANCECHANGETILES: SET_COMBOCLASS_VAR_INT(distance_change_tiles, "DistanceChangeTiles"); break; //LONG
25395 case COMBODDIVEITEM: SET_COMBOCLASS_VAR_DWORD(dive_item, "DiveItem"); break; //SHORT
25396 case COMBODDOCK: SET_COMBOCLASS_VAR_BYTE(dock, "Dock"); break; //C
25397 case COMBODFAIRY: SET_COMBOCLASS_VAR_BYTE(fairy, "Fairy"); break; //C
25398 case COMBODFFATTRCHANGE: SET_COMBOCLASS_VAR_BYTE(ff_combo_attr_change, "FFCAttributeChange"); break; //C
25399 case COMBODFOORDECOTILE: SET_COMBOCLASS_VAR_INT(foot_decorations_tile, "DecorationTile"); break; //LONG
25400 case COMBODFOORDECOTYPE: SET_COMBOCLASS_VAR_BYTE(foot_decorations_type, "DecorationType"); break; //C
25401 case COMBODHOOKSHOTPOINT: SET_COMBOCLASS_VAR_BYTE(hookshot_grab_point, "Hookshot"); break; //C
25402 case COMBODLADDERPASS: SET_COMBOCLASS_VAR_BYTE(ladder_pass, "Ladder"); break; //C
25403 case COMBODLOCKBLOCK: SET_COMBOCLASS_VAR_BYTE(lock_block_type, "LockBlock"); break; //C
25404 case COMBODLOCKBLOCKCHANGE: SET_COMBOCLASS_VAR_INT(lock_block_change, "LockBlockChange"); break; //LONG
25405 case COMBODMAGICMIRROR: SET_COMBOCLASS_VAR_BYTE(magic_mirror_type, "Mirror"); break; //C
25406 case COMBODMODHPAMOUNT: SET_COMBOCLASS_VAR_DWORD(modify_hp_amount, "DamageAmount"); break; //SHORT
25407 case COMBODMODHPDELAY: SET_COMBOCLASS_VAR_BYTE(modify_hp_delay, "DamageDelay"); break; //C
25408 case COMBODMODHPTYPE: SET_COMBOCLASS_VAR_BYTE(modify_hp_type, "DamageType"); break; //C
25409 case COMBODNMODMPAMOUNT: SET_COMBOCLASS_VAR_DWORD(modify_mp_amount, "MagicAmount"); break; //SHORT
25410 case COMBODMODMPDELAY: SET_COMBOCLASS_VAR_BYTE(modify_mp_delay, "MagicDelay"); break; //C
25411 case COMBODMODMPTYPE: SET_COMBOCLASS_VAR_BYTE(modify_mp_type, "MagicType"); break; //C
25412 case COMBODNOPUSHBLOCK: SET_COMBOCLASS_VAR_BYTE(no_push_blocks, "NoPushBlocks"); break; //C
25413 case COMBODOVERHEAD: SET_COMBOCLASS_VAR_BYTE(overhead, "Overhead"); break; //C
25414 case COMBODPLACENPC: SET_COMBOCLASS_VAR_BYTE(place_enemy, "PlaceNPC"); break; //C
25415 case COMBODPUSHDIR: SET_COMBOCLASS_VAR_BYTE(push_direction, "PushDir"); break; //C
25416 case COMBODPUSHWAIT: SET_COMBOCLASS_VAR_BYTE(push_wait, "PushDelay"); break; //C
25417 case COMBODPUSHHEAVY: SET_COMBOCLASS_VAR_BYTE(push_weight, "PushHeavy"); break; //C
25418 case COMBODPUSHED: SET_COMBOCLASS_VAR_BYTE(pushed, "Pushed"); break; //C
25419 case COMBODRAFT: SET_COMBOCLASS_VAR_BYTE(raft, "Raft"); break; //C
25420 case COMBODRESETROOM: SET_COMBOCLASS_VAR_BYTE(reset_room, "ResetRoom"); break; //C
25421 case COMBODSAVEPOINTTYPE: SET_COMBOCLASS_VAR_BYTE(save_point_type, "SavePoint"); break; //C
25422 case COMBODSCREENFREEZETYPE: SET_COMBOCLASS_VAR_BYTE(screen_freeze_type, "FreezeScreen"); break; //C
25423 case COMBODSECRETCOMBO: SET_COMBOCLASS_VAR_BYTE(secret_combo, "SecretCombo"); break; //C
25424 case COMBODSINGULAR: SET_COMBOCLASS_VAR_BYTE(singular, "Singular"); break; //C
25425 case COMBODSLOWWALK: SET_COMBOCLASS_VAR_BYTE(slow_movement, "SlowWalk"); break; //C
25426 case COMBODSTATUETYPE: SET_COMBOCLASS_VAR_BYTE(statue_type, "Statue"); break; //C
25427 case COMBODSTEPTYPE: SET_COMBOCLASS_VAR_BYTE(step_type, "Step"); break; //C
25428 case COMBODSTEPCHANGEINTO: SET_COMBOCLASS_VAR_INT(step_change_to, "StepChange"); break; //LONG
25429 case COMBODSTRIKEWEAPONS: SET_COMBOCLASS_BYTE_INDEX(strike_weapons, "Strike[]", 32); break; //BYTE, 32 INDICES.
25430 case COMBODSTRIKEREMNANTS: SET_COMBOCLASS_VAR_INT(strike_remnants, "StrikeRemnants"); break; //LONG
25431 case COMBODSTRIKEREMNANTSTYPE: SET_COMBOCLASS_VAR_BYTE(strike_remnants_type, "StrikeRemnantsType"); break; //C
25432 case COMBODSTRIKECHANGE: SET_COMBOCLASS_VAR_INT(strike_change, "StrikeChange"); break; //LONG
25433 case COMBODSTRIKEITEM: SET_COMBOCLASS_VAR_DWORD(strike_item, "StrikeItem"); break; //SHORT
25434 case COMBODTOUCHITEM: SET_COMBOCLASS_VAR_DWORD(touch_item, "TouchItem"); break; //SHORT
25435 case COMBODTOUCHSTAIRS: SET_COMBOCLASS_VAR_BYTE(touch_stairs, "TouchStairs"); break; //C
25436 case COMBODTRIGGERTYPE: SET_COMBOCLASS_VAR_BYTE(trigger_type, "TriggerType"); break; //C
25437 case COMBODTRIGGERSENS: SET_COMBOCLASS_VAR_BYTE(trigger_sensitive, "TriggerSensitivity"); break; //C
25438 case COMBODWARPTYPE: SET_COMBOCLASS_VAR_BYTE(warp_type, "Warp"); break; //C
25439 case COMBODWARPSENS: SET_COMBOCLASS_VAR_BYTE(warp_sensitive, "WarpSensitivity"); break; //C
25440 case COMBODWARPDIRECT: SET_COMBOCLASS_VAR_BYTE(warp_direct, "WarpDirect"); break; //C
25441 case COMBODWARPLOCATION: SET_COMBOCLASS_VAR_BYTE(warp_location, "WarpLocation"); break; //C
25442 case COMBODWATER: SET_COMBOCLASS_VAR_BYTE(water, "Liquid"); break; //C
25443 case COMBODWHISTLE: SET_COMBOCLASS_VAR_BYTE(whistle, "Whistle"); break; //C
25444 case COMBODWINGAME: SET_COMBOCLASS_VAR_BYTE(win_game, "WinGame"); break; //C
25445 case COMBODBLOCKWPNLEVEL: SET_COMBOCLASS_VAR_BYTE(block_weapon_lvl, "BlockWeaponLevel"); break; //C
25446
25447
25448
25449 ///----------------------------------------------------------------------------------------------------//
25450 //npcdata nd-> Variables
25451
25452 #define SET_NPCDATA_VAR_INT(member, str) \
25453 { \
25454 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
25455 { \
25456 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
25457 } \
25458 else \
25459 { \
25460 guysbuf[ri->npcdataref].member = vbound((value / 10000),0,214747); \
25461 } \
25462 } \
25463
25464 #define SET_NPCDATA_VAR_DWORD(member, str) \
25465 { \
25466 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
25467 { \
25468 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
25469 } \
25470 else \
25471 { \
25472 guysbuf[ri->npcdataref].member = vbound((value / 10000),0,32767); \
25473 } \
25474 } \
25475
25476 #define SET_NPCDATA_VAR_BYTE(member, str) \
25477 { \
25478 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
25479 { \
25480 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
25481 } \
25482 else \
25483 { \
25484 guysbuf[ri->npcdataref].member = vbound((value / 10000),0,255); \
25485 } \
25486 } \
25487
25488 #define SET_NPCDATA_VAR_INDEX(member, str, indexbound) \
25489 { \
25490 int32_t indx = ri->d[rINDEX] / 10000; \
25491 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
25492 { \
25493 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
25494 } \
25495 else if ( (unsigned)indx > indexbound ) \
25496 { \
25497 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", indx, str); \
25498 } \
25499 else \
25500 { \
25501 guysbuf[ri->npcdataref].member[indx] = vbound((value / 10000),0,214747); \
25502 } \
25503 }
25504
25505 #define SET_NPCDATA_BYTE_INDEX(member, str, indexbound) \
25506 { \
25507 int32_t indx = ri->d[rINDEX] / 10000; \
25508 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
25509 { \
25510 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
25511 } \
25512 else if ( (unsigned)indx > indexbound ) \
25513 { \
25514 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", indx, str); \
25515 } \
25516 else \
25517 { \
25518 guysbuf[ri->npcdataref].member[indx] = vbound((value / 10000),0,255); \
25519 } \
25520 }
25521
25522 #define SET_NPCDATA_FLAG(member, str) \
25523 { \
25524 int32_t flag = (value/10000); \
25525 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
25526 { \
25527 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
25528 } \
25529 else \
25530 { \
25531 if ( flag ) \
25532 { \
25533 guysbuf[ri->npcdataref].member|=flag; \
25534 } \
25535 else guysbuf[ri->npcdataref].member|= ~flag; \
25536 } \
25537 } \
25538
25539 case NPCDATATILE: SET_NPCDATA_VAR_BYTE(tile, "Tile"); break;
25540 case NPCDATAWIDTH: SET_NPCDATA_VAR_BYTE(width, "Width"); break;
25541 case NPCDATAHEIGHT: SET_NPCDATA_VAR_BYTE(height, "Height"); break;
25542 case NPCDATAFLAGS: SET_NPCDATA_VAR_DWORD(flags, "Flags"); break; //16 b its
25543 case NPCDATAFLAGS2: SET_NPCDATA_VAR_DWORD(flags2, "Flags2"); break; //16 bits
25544 case NPCDATASTILE: SET_NPCDATA_VAR_BYTE(s_tile, "STile"); break;
25545 case NPCDATASWIDTH: SET_NPCDATA_VAR_BYTE(s_width, "SWidth"); break;
25546 case NPCDATASHEIGHT: SET_NPCDATA_VAR_BYTE(s_height, "SHeight"); break;
25547 case NPCDATAETILE: SET_NPCDATA_VAR_INT(e_tile, "ExTile"); break;
25548 case NPCDATAEWIDTH: SET_NPCDATA_VAR_BYTE(e_width, "ExWidth"); break;
25549 case NPCDATASCRIPT: SET_NPCDATA_VAR_BYTE(script, "Script"); break;
25550 case NPCDATAEHEIGHT: SET_NPCDATA_VAR_BYTE(e_height, "ExHeight"); break;
25551 case NPCDATAHP: SET_NPCDATA_VAR_DWORD(hp, "HP"); break;
25552 case NPCDATAFAMILY: SET_NPCDATA_VAR_DWORD(family, "Family"); break;
25553 case NPCDATACSET: SET_NPCDATA_VAR_DWORD(cset, "CSet"); break;
25554 case NPCDATAANIM: SET_NPCDATA_VAR_DWORD(anim, "Anim"); break;
25555 case NPCDATAEANIM: SET_NPCDATA_VAR_DWORD(e_anim, "ExAnim"); break;
25556 case NPCDATAFRAMERATE: SET_NPCDATA_VAR_DWORD(frate, "Framerate"); break;
25557 case NPCDATAEFRAMERATE: SET_NPCDATA_VAR_DWORD(e_frate, "ExFramerate"); break;
25558 case NPCDATATOUCHDAMAGE: SET_NPCDATA_VAR_DWORD(dp, "TouchDamage"); break;
25559 case NPCDATAWEAPONDAMAGE: SET_NPCDATA_VAR_DWORD(wdp, "WeaponDamage"); break;
25560 case NPCDATAWEAPON: SET_NPCDATA_VAR_DWORD(weapon, "Weapon"); break;
25561 case NPCDATARANDOM: SET_NPCDATA_VAR_DWORD(rate, "Random"); break;
25562 case NPCDATAHALT: SET_NPCDATA_VAR_DWORD(hrate, "Haltrate"); break;
25563 case NPCDATASTEP: SET_NPCDATA_VAR_DWORD(step, "Step"); break;
25564 case NPCDATAHOMING: SET_NPCDATA_VAR_DWORD(homing, "Homing"); break;
25565 case NPCDATAHUNGER: SET_NPCDATA_VAR_DWORD(grumble, "Hunger"); break;
25566 case NPCDATADROPSET: SET_NPCDATA_VAR_DWORD(item_set, "Dropset"); break;
25567 case NPCDATABGSFX: SET_NPCDATA_VAR_DWORD(bgsfx, "BGSFX"); break;
25568 case NPCDATADEATHSFX: SET_NPCDATA_VAR_BYTE(deadsfx, "DeathSFX"); break;
25569 case NPCDATAHITSFX: SET_NPCDATA_VAR_BYTE(hitsfx, "HitSFX"); break;
25570 case NPCDATAXOFS: SET_NPCDATA_VAR_INT(xofs, "DrawXOffset"); break;
25571 case NPCDATAYOFS: SET_NPCDATA_VAR_INT(yofs, "DrawYOffset"); break;
25572 case NPCDATAZOFS: SET_NPCDATA_VAR_INT(zofs, "DrawZOffset"); break;
25573 case NPCDATAHXOFS: SET_NPCDATA_VAR_INT(hxofs, "HitXOffset"); break;
25574 case NPCDATAHYOFS: SET_NPCDATA_VAR_INT(hyofs, "HitYOffset"); break;
25575 case NPCDATAHITWIDTH: SET_NPCDATA_VAR_INT(hxsz, "HitWidth"); break;
25576 case NPCDATAHITHEIGHT: SET_NPCDATA_VAR_INT(hysz, "HitHeight"); break;
25577 case NPCDATAHITZ: SET_NPCDATA_VAR_INT(hzsz, "HitZHeight"); break;
25578 case NPCDATATILEWIDTH: SET_NPCDATA_VAR_INT(txsz, "TileWidth"); break;
25579 case NPCDATATILEHEIGHT: SET_NPCDATA_VAR_INT(tysz, "TileHeight"); break;
25580 case NPCDATAWPNSPRITE: SET_NPCDATA_VAR_INT(wpnsprite, "WeaponSprite"); break;
25581 case NPCDATAWEAPONSCRIPT: SET_NPCDATA_VAR_INT(weaponscript, "WeaponScript"); break;
25582 case NPCDATADEFENSE: SET_NPCDATA_VAR_INDEX(defense, "Defense", 42); break;
25583 case NPCDATAWEAPONINITD: SET_NPCDATA_VAR_INDEX(weap_initiald, "WeaponInitD", 8); break;
25584 case NPCDATAINITD: SET_NPCDATA_VAR_INDEX(initD, "InitD", 8); break;
25585 case NPCDATASIZEFLAG: SET_NPCDATA_VAR_INT(SIZEflags, "SizeFlags"); break;
25586
25587 case NPCDATAFROZENTILE: SET_NPCDATA_VAR_INT(frozentile, "FrozenTile"); break;
25588 case NPCDATAFROZENCSET: SET_NPCDATA_VAR_INT(frozencset, "FrozenCSet"); break;
25589
25590 case NPCDATAATTRIBUTE:
25591 {
25592 int32_t indx = ri->d[rINDEX] / 10000;
25593 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
25594 {
25595 Z_scripterrlog("Invalid Sprite ID passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
25596 }
25597 else if ( indx < 0 || indx > MAX_NPC_ATRIBUTES )
25598 {
25599 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
25600 }
25601 else
25602 {
25603 switch(indx)
25604 {
25605 case 0: guysbuf[ri->npcdataref].misc1 = (value / 10000); break;
25606 case 1: guysbuf[ri->npcdataref].misc2 = (value / 10000); break;
25607 case 2: guysbuf[ri->npcdataref].misc3 = (value / 10000); break;
25608 case 3: guysbuf[ri->npcdataref].misc4 = (value / 10000); break;
25609 case 4: guysbuf[ri->npcdataref].misc5 = (value / 10000); break;
25610 case 5: guysbuf[ri->npcdataref].misc6 = (value / 10000); break;
25611 case 6: guysbuf[ri->npcdataref].misc7 = (value / 10000); break;
25612 case 7: guysbuf[ri->npcdataref].misc8 = (value / 10000); break;
25613 case 8: guysbuf[ri->npcdataref].misc9 = (value / 10000); break;
25614 case 9: guysbuf[ri->npcdataref].misc10 = (value / 10000); break;
25615 case 10: guysbuf[ri->npcdataref].misc11 = (value / 10000); break;
25616 case 11: guysbuf[ri->npcdataref].misc12 = (value / 10000); break;
25617 case 12: guysbuf[ri->npcdataref].misc13 = (value / 10000); break;
25618 case 13: guysbuf[ri->npcdataref].misc14 = (value / 10000); break;
25619 case 14: guysbuf[ri->npcdataref].misc15 = (value / 10000); break;
25620
25621 case 15: guysbuf[ri->npcdataref].misc16 = value / 10000; break;
25622 case 16: guysbuf[ri->npcdataref].misc17 = value / 10000; break;
25623 case 17: guysbuf[ri->npcdataref].misc18 = value / 10000; break;
25624 case 18: guysbuf[ri->npcdataref].misc19 = value / 10000; break;
25625 case 19: guysbuf[ri->npcdataref].misc20 = value / 10000; break;
25626 case 20: guysbuf[ri->npcdataref].misc21 = value / 10000; break;
25627 case 21: guysbuf[ri->npcdataref].misc22 = value / 10000; break;
25628 case 22: guysbuf[ri->npcdataref].misc23 = value / 10000; break;
25629 case 23: guysbuf[ri->npcdataref].misc24 = value / 10000; break;
25630 case 24: guysbuf[ri->npcdataref].misc25 = value / 10000; break;
25631 case 25: guysbuf[ri->npcdataref].misc26 = value / 10000; break;
25632 case 26: guysbuf[ri->npcdataref].misc27 = value / 10000; break;
25633 case 27: guysbuf[ri->npcdataref].misc28 = value / 10000; break;
25634 case 28: guysbuf[ri->npcdataref].misc29 = value / 10000; break;
25635 case 29: guysbuf[ri->npcdataref].misc30 = value / 10000; break;
25636 case 30: guysbuf[ri->npcdataref].misc31 = value / 10000; break;
25637 case 31: guysbuf[ri->npcdataref].misc32 = value / 10000; break;
25638
25639 default:
25640 {
25641 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
25642 break;
25643 }
25644 }
25645
25646 }
25647 break;
25648 }
25649
25650 case NPCDATABEHAVIOUR:
25651 {
25652 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
25653 {
25654 break;
25655 }
25656
25657
25658 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
25659 switch(index){
25660 case 0:
25661 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG1 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG1;
25662 break;
25663 case 1:
25664 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG2 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG2;
25665 break;
25666 case 2:
25667 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG3 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG3;
25668 break;
25669 case 3:
25670 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG4 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG4;
25671 break;
25672 case 4:
25673 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG5 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG5;
25674 break;
25675 case 5:
25676 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG6 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG6;
25677 break;
25678 case 6:
25679 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG7 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG7;
25680 break;
25681 case 7:
25682 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG8 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG8;
25683 break;
25684 case 8:
25685 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG9 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG9;
25686 break;
25687 case 9:
25688 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG10 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG10;
25689 break;
25690 case 10:
25691 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG11 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG11;
25692 break;
25693 case 11:
25694 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG12 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG12;
25695 break;
25696 case 12:
25697 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG13 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG13;
25698 break;
25699 case 13:
25700 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG14 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG14;
25701 break;
25702 case 14:
25703 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG15 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG15;
25704 break;
25705 case 15:
25706 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG16 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG16;
25707 break;
25708
25709
25710 default:
25711 break;
25712 }
25713
25714 break;
25715 }
25716
25717 case NPCDATASHIELD:
25718 {
25719 int32_t indx = ri->d[rINDEX] / 10000;
25720 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
25721 {
25722 Z_scripterrlog("Invalid NPC ID passed to npcdata->Shield[]: %d\n", (ri->npcdataref*10000));
25723 break;
25724 }
25725 else
25726 {
25727 switch(indx)
25728 {
25729 case 0:
25730 {
25731 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_front) : (guysbuf[ri->npcdataref].flags &= ~inv_front);
25732 break;
25733 }
25734 case 1:
25735 {
25736 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_left) : (guysbuf[ri->npcdataref].flags &= ~inv_left);
25737 break;
25738 }
25739 case 2:
25740 {
25741 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_right) : (guysbuf[ri->npcdataref].flags &= ~inv_right);
25742 break;
25743 }
25744 case 3:
25745 {
25746 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_back) : (guysbuf[ri->npcdataref].flags &= ~inv_back);
25747 break;
25748 }
25749 case 4:
25750 {
25751 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= guy_bkshield) : (guysbuf[ri->npcdataref].flags &= ~guy_bkshield);
25752 break;
25753 }
25754 default:
25755 {
25756 Z_scripterrlog("Invalid Array Index passed to npcdata->Shield[]: %d\n", indx);
25757 break;
25758 }
25759 }
25760 break;
25761 }
25762 }
25763
25764 case NPCDSHADOWSPR:
25765 {
25766 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
25767 {
25768 Z_scripterrlog("Invalid NPC ID passed to npcdata->ShadowSprite: %d\n", (ri->npcdataref*10000));
25769 }
25770 else
25771 {
25772 guysbuf[ri->npcdataref].spr_shadow = vbound(value/10000, 0, 255);
25773 }
25774 break;
25775 }
25776 case NPCDSPAWNSPR:
25777 {
25778 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
25779 {
25780 Z_scripterrlog("Invalid NPC ID passed to npcdata->SpawnSprite: %d\n", (ri->npcdataref*10000));
25781 }
25782 else
25783 {
25784 guysbuf[ri->npcdataref].spr_spawn = vbound(value/10000, 0, 255);
25785 }
25786 break;
25787 }
25788 case NPCDDEATHSPR:
25789 {
25790 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
25791 {
25792 Z_scripterrlog("Invalid NPC ID passed to npcdata->DeathSprite: %d\n", (ri->npcdataref*10000));
25793 }
25794 else
25795 {
25796 guysbuf[ri->npcdataref].spr_death = vbound(value/10000, 0, 255);
25797 }
25798 break;
25799 }
25800
25801
25802 ///----------------------------------------------------------------------------------------------------//
25803 //Dropset Variables
25804
25805 case DROPSETITEMS:
25806 {
25807 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
25808 {
25809 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
25810 break;
25811 }
25812 int32_t indx = ri->d[rINDEX]/10000;
25813 if(indx < 0 || indx > 9)
25814 {
25815 Z_scripterrlog("Invalid index passed to dropdata->Items[]: %d\n", indx);
25816 }
25817 else
25818 {
25819 item_drop_sets[ri->dropsetref].item[indx] = vbound(value / 10000, 0, MAXITEMS-1);
25820 }
25821 break;
25822 }
25823 case DROPSETCHANCES:
25824 {
25825 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
25826 {
25827 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
25828 break;
25829 }
25830 int32_t indx = ri->d[rINDEX]/10000;
25831 if(indx < 0 || indx > 9)
25832 {
25833 Z_scripterrlog("Invalid index passed to dropdata->Chances[]: %d\n", indx);
25834 }
25835 else
25836 {
25837 item_drop_sets[ri->dropsetref].chance[indx+1] = vbound((value / 10000),0,32767); //+1 is because '0' is 'nothing''s chance
25838 }
25839 break;
25840 }
25841 case DROPSETNULLCHANCE:
25842 {
25843 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
25844 {
25845 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
25846 break;
25847 }
25848 item_drop_sets[ri->dropsetref].chance[0] = vbound((value / 10000),0,32767);
25849 break;
25850 }
25851
25852 ///----------------------------------------------------------------------------------------------------//
25853 //Audio Variables
25854
25855 case AUDIOVOLUME:
25856 {
25857 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
25858 break;
25859
25860 int32_t indx = ri->d[rINDEX] / 10000;
25861 //zprint("Volume[index] is: %d", indx);
25862 //int32_t vol = value / 10000;
25863 //zprint("Attempted to change volume to: %d", vol);
25864 switch(indx)
25865 {
25866
25867 case 0: //midi volume
25868 {
25869 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME) )
25870 {
25871 FFCore.usr_midi_volume = FFScript::do_getMIDI_volume();
25872 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_MIDI_VOLUME,true);
25873 }
25874 FFScript::do_setMIDI_volume(value / 10000);
25875 break;
25876 }
25877 case 1: //digi volume
25878 {
25879 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME) )
25880 {
25881 FFCore.usr_digi_volume = FFScript::do_getDIGI_volume();
25882 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_DIGI_VOLUME,true);
25883 }
25884 FFScript::do_setDIGI_volume(value / 10000);
25885 break;
25886 }
25887 case 2: //emh music volume
25888 {
25889 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME) )
25890 {
25891 FFCore.usr_music_volume = FFScript::do_getMusic_volume();
25892 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_MUSIC_VOLUME,true);
25893 }
25894 FFScript::do_setMusic_volume(value / 10000);
25895 break;
25896 }
25897 case 3: //sfx volume
25898 {
25899 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME) )
25900 {
25901 FFCore.usr_sfx_volume = FFScript::do_getSFX_volume();
25902 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_SFX_VOLUME,true);
25903 }
25904 FFScript::do_setSFX_volume(value / 10000);
25905 break;
25906 }
25907 default:
25908 {
25909 Z_scripterrlog("Attempted to access an invalid index of Audio->Volume[]", indx);
25910 break;
25911 }
25912 }
25913 break;
25914 }
25915
25916 case AUDIOPAN:
25917 {
25918 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE) )
25919 {
25920 FFCore.usr_panstyle = FFScript::do_getSFX_pan();
25921 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_PANSTYLE,true);
25922 }
25923 FFScript::do_setSFX_pan(value/10000);
25924 break;
25925 }
25926
25927 ///----------------------------------------------------------------------------------------------------//
25928 //Graphics->
25929
25930 case NUMDRAWS:
25931 break;
25932
25933 case MAXDRAWS: break;
25934
25935 ///----------------------------------------------------------------------------------------------------//
25936 //Module->
25937 case MODULEGETSTR:
25938 {
25939 int32_t buf_pointer = ((ri->d[rINDEX])/10000);
25940 int32_t section_pointer = ((ri->d[rINDEX2])/10000);
25941 int32_t element_pointer = (value/10000);
25942
25943 string sectionid;
25944 string elementid;
25945
25946 ArrayH::getString(section_pointer, sectionid);
25947 ArrayH::getString(element_pointer, elementid);
25948
25949 char buffer[256] = {0};
25950
25951
25952 if(!fileexists((char*)moduledata.module_name))
25953 {
25954 Z_scripterrlog("I/O Error: No module definitions found when using Module->GetString()\n");
25955 }
25956 else
25957 {
25958 zc_push_config();
25959 //set config file
25960 zc_config_file(moduledata.module_name);
25961 strcpy(buffer,zc_get_config_basic(sectionid.c_str(), elementid.c_str(), ""));
25962 buffer[255] = '\0';
25963 if(ArrayH::setArray(buf_pointer, buffer) == SH::_Overflow)
25964 Z_scripterrlog("Dest string supplied to 'Module->GetString()' is not large enough\n");
25965 //return config file to zc.cfg
25966 zc_pop_config();
25967 }
25968
25969 break;
25970 }
25971
25972 ///----------------------------------------------------------------------------------------------------//
25973 //Misc./Internal
25974 case SP:
25975 ri->sp = value / 10000;
25976 ri->sp &= MASK_SP;
25977 break;
25978
25979 case PC:
25980 ri->pc = value;
25981 break;
25982
25983 case SWITCHKEY:
25984 ri->switchkey = value;
25985 break;
25986
25987 case SCRIPTRAM:
25988 case GLOBALRAM:
25989 455505918 ArrayH::setElement(ri->d[rINDEX] / 10000, ri->d[rINDEX2] / 10000, value);
25990 455505918 break;
25991
25992 case SCRIPTRAMD:
25993 case GLOBALRAMD:
25994 ArrayH::setElement(ri->d[rINDEX] / 10000, 0, value);
25995 break;
25996
25997 case REFFFC:
25998 503812260 ri->ffcref = value / 10000;
25999 503812260 break;
26000
26001 case REFITEM:
26002 409929 ri->itemref = value;
26003 409929 break;
26004
26005 case REFITEMCLASS:
26006 375716 ri->idata = value;
26007 375716 break;
26008
26009 case REFLWPN:
26010 10112990 ri->lwpn = value;
26011 10112990 break;
26012
26013 case REFEWPN:
26014 23554631 ri->ewpn = value;
26015 23554631 break;
26016
26017 case REFNPC:
26018 78146347 ri->guyref = value;
26019 78146347 break;
26020
26021 18513311 case REFMAPDATA: ri->mapsref = value; break;
26022 case REFSCREENDATA: ri->screenref = value; break;
26023 116558 case REFCOMBODATA: ri->combosref = value; break;
26024 case REFSPRITEDATA: ri->spritesref = value; break;
26025 257126 case REFBITMAP: ri->bitmapref = value; break;
26026 case REFNPCCLASS: ri->npcdataref = value; break;
26027
26028 760115 case REFDMAPDATA: ri->dmapsref = value; break;
26029 case REFSHOPDATA: ri->shopsref = value; break;
26030 case REFMSGDATA: ri->zmsgref = value; break;
26031 case REFUNTYPED: ri->untypedref = value; break;
26032
26033
26034 case REFDROPS: ri->dropsetref = value; break;
26035 case REFBOTTLETYPE: ri->bottletyperef = value; break;
26036 case REFBOTTLESHOP: ri->bottleshopref = value; break;
26037 142 case REFGENERICDATA: ri->genericdataref = value; break;
26038 case REFPONDS: ri->pondref = value; break;
26039 case REFWARPRINGS: ri->warpringref = value; break;
26040 case REFDOORS: ri->doorsref = value; break;
26041 case REFUICOLOURS: ri->zcoloursref = value; break;
26042 case REFRGB: ri->rgbref = value; break;
26043 case REFPALETTE: ri->paletteref = value; break;
26044 case REFTUNES: ri->tunesref = value; break;
26045 case REFPALCYCLE: ri->palcycleref = value; break;
26046 case REFGAMEDATA: ri->gamedataref = value; break;
26047 case REFCHEATS: ri->cheatsref = value; break;
26048 284 case REFFILE: ri->fileref = value; break;
26049 case REFDIRECTORY: ri->directoryref = value; break;
26050 case REFSTACK: ri->stackref = value; break;
26051 case REFSUBSCREEN: ri->subdataref = value; break;
26052 case REFSUBSCREENPAGE: ri->subpageref = value; break;
26053 case REFSUBSCREENWIDG: ri->subwidgref = value; break;
26054 303330 case REFRNG: ri->rngref = value; break;
26055 case CLASS_THISKEY: ri->thiskey = value; break;
26056 case CLASS_THISKEY2: ri->thiskey2 = value; break;
26057 case REFPALDATA: ri->paldataref = value; break;
26058
26059 //-------------------------------------------------------------------------------------------------
26060
26061 case PALDATACOLOR:
26062 {
26063 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->SetColor()"))
26064 {
26065 int32_t ind = ri->d[rINDEX] / 10000;
26066 if (unsigned(ind) >= PALDATA_NUM_COLORS)
26067 {
26068 Z_scripterrlog("Invalid color index (%d) passed to paldata->SetColor(). Valid indices are 0-255. Aborting.\n", ind);
26069 break;
26070 }
26071 int32_t clri = value;
26072
26073 RGB c = _RGB((clri >> 16) & 0xFF, (clri >> 8) & 0xFF, clri & 0xFF);
26074
26075 if (c.r < 0 || c.g < 0 || c.b < 0)
26076 {
26077 Z_scripterrlog("Invalid rgb (%d) passed to paldata->SetColor().\n", clri);
26078 }
26079 c.r = vbound(c.r, 0, 63);
26080 c.g = vbound(c.g, 0, 63);
26081 c.b = vbound(c.b, 0, 63);
26082
26083 pd->set_color(ind, c);
26084 }
26085 break;
26086 }
26087 case PALDATAR:
26088 FFCore.do_paldata_setrgb(0, value / 10000);
26089 break;
26090 case PALDATAG:
26091 FFCore.do_paldata_setrgb(1, value / 10000);
26092 break;
26093 case PALDATAB:
26094 FFCore.do_paldata_setrgb(2, value / 10000);
26095 break;
26096
26097 //-------------------------------------------------------------------------------------------------
26098
26099 case GENDATARUNNING:
26100 {
26101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Running"))
26102 {
26103
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(value)
26104 58 scr->launch();
26105 else scr->quit();
26106 58 }
26107 58 break;
26108 }
26109 case GENDATASIZE:
26110 {
26111 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "DataSize"))
26112 {
26113 scr->dataResize(value/10000);
26114 }
26115 break;
26116 }
26117 case GENDATAEXITSTATE:
26118 {
26119 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ExitState"))
26120 {
26121 size_t indx = ri->d[rINDEX]/10000;
26122 if(indx >= GENSCR_NUMST)
26123 {
26124 Z_scripterrlog("Invalid index passed to genericdata->ReloadState[]: %d\n", indx);
26125 break;
26126 }
26127 SETFLAG(scr->exitState, (1<<indx), value);
26128 }
26129 break;
26130 }
26131 case GENDATARELOADSTATE:
26132 {
26133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ReloadState"))
26134 {
26135 74 size_t indx = ri->d[rINDEX]/10000;
26136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(indx >= GENSCR_NUMST)
26137 {
26138 Z_scripterrlog("Invalid index passed to genericdata->ReloadState[]: %d\n", indx);
26139 break;
26140 }
26141
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 SETFLAG(scr->reloadState, (1<<indx), value);
26142 74 }
26143 74 break;
26144 }
26145 case GENDATAEVENTSTATE:
26146 {
26147 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "EventListen"))
26148 {
26149 size_t indx = ri->d[rINDEX]/10000;
26150 if(indx >= GENSCR_NUMEVENT)
26151 {
26152 Z_scripterrlog("Invalid index passed to genericdata->EventListen[]: %d\n", indx);
26153 break;
26154 }
26155 SETFLAG(scr->eventstate, (1<<indx), value);
26156 }
26157 break;
26158 }
26159 case GENDATADATA:
26160 {
26161 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Data[]"))
26162 {
26163 size_t indx = ri->d[rINDEX]/10000;
26164 if(indx >= scr->dataSize())
26165 {
26166 Z_scripterrlog("Invalid index passed to genericdata->Data[]: %d\n", indx);
26167 break;
26168 }
26169 scr->data[indx] = value;
26170 }
26171 break;
26172 }
26173 case GENDATAINITD:
26174 {
26175 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "InitD[]"))
26176 {
26177 size_t indx = ri->d[rINDEX]/10000;
26178 if(indx >= 8)
26179 {
26180 Z_scripterrlog("Invalid index passed to genericdata->InitD[]: %d\n", indx);
26181 break;
26182 }
26183 scr->initd[indx] = value;
26184 }
26185 break;
26186 }
26187
26188 //----------------------------------------------------------------------------------------------------//
26189
26190 case PORTALX:
26191 {
26192 if(portal* p = checkPortal(ri->portalref, "X"))
26193 p->x = zslongToFix(value);
26194 break;
26195 }
26196 case PORTALY:
26197 {
26198 if(portal* p = checkPortal(ri->portalref, "Y"))
26199 p->y = zslongToFix(value);
26200 break;
26201 }
26202 case PORTALDMAP:
26203 {
26204 if(portal* p = checkPortal(ri->portalref, "DMap"))
26205 p->destdmap = vbound(value/10000,-1,MAXDMAPS-1);
26206 break;
26207 }
26208 case PORTALSCREEN:
26209 {
26210 if(portal* p = checkPortal(ri->portalref, "Screen"))
26211 p->destscr = vbound(value/10000,0,255);
26212 break;
26213 }
26214 case PORTALACLK:
26215 {
26216 if(portal* p = checkPortal(ri->portalref, "AClk"))
26217 p->aclk = vbound(value/10000, 0, 9999);
26218 break;
26219 }
26220 case PORTALAFRM:
26221 {
26222 if(portal* p = checkPortal(ri->portalref, "AFrame"))
26223 p->aframe = vbound(value/10000, 0, 9999);
26224 break;
26225 }
26226 case PORTALOTILE:
26227 {
26228 if(portal* p = checkPortal(ri->portalref, "OriginalTile"))
26229 p->o_tile = vbound(value/10000, 0, NEWMAXTILES-1);
26230 break;
26231 }
26232 case PORTALASPD:
26233 {
26234 if(portal* p = checkPortal(ri->portalref, "ASpeed"))
26235 p->aspd = vbound(value/10000, 0, 9999);
26236 break;
26237 }
26238 case PORTALFRAMES:
26239 {
26240 if(portal* p = checkPortal(ri->portalref, "Frames"))
26241 p->frames = vbound(value/10000, 0, 9999);
26242 break;
26243 }
26244 case PORTALSAVED:
26245 {
26246 if(ri->portalref < 0 || value < 0) break;
26247 if(portal* p = checkPortal(ri->portalref, "SavedPortal"))
26248 {
26249 if(!value)
26250 p->saved_data = 0;
26251 else if(savedportal* sp = checkSavedPortal(value, "portal->SavedPortal"))
26252 p->saved_data = sp->getUID();
26253 }
26254 break;
26255 }
26256 case PORTALCLOSEDIS:
26257 {
26258 if(portal* p = checkPortal(ri->portalref, "CloseDisabled"))
26259 p->prox_active = value==0; //Inverted
26260 break;
26261 }
26262 case REFPORTAL:
26263 {
26264 ri->portalref = value;
26265 break;
26266 }
26267 case REFSAVPORTAL:
26268 {
26269 ri->saveportalref = value;
26270 break;
26271 }
26272 case PORTALWARPSFX:
26273 {
26274 if(portal* p = checkPortal(ri->portalref, "WarpSFX"))
26275 p->wsfx = vbound(value/10000,0,255);
26276 break;
26277 }
26278 case PORTALWARPVFX:
26279 {
26280 if(portal* p = checkPortal(ri->portalref, "WarpEffect"))
26281 p->weffect = vbound(value/10000,0,255);
26282 break;
26283 }
26284 case SAVEDPORTALX:
26285 {
26286 if(savedportal* p = checkSavedPortal(ri->saveportalref, "X"))
26287 p->x = value;
26288 break;
26289 }
26290 case SAVEDPORTALY:
26291 {
26292 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Y"))
26293 p->y = value;
26294 break;
26295 }
26296 case SAVEDPORTALSRCDMAP:
26297 {
26298 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcDMap"))
26299 p->srcdmap = vbound(value/10000, -1, MAXDMAPS-1);
26300 break;
26301 }
26302 case SAVEDPORTALDESTDMAP:
26303 {
26304 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestDMap"))
26305 p->destdmap = vbound(value/10000, -1, MAXDMAPS-1);
26306 break;
26307 }
26308 case SAVEDPORTALSRCSCREEN:
26309 {
26310 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcScreen"))
26311 p->srcscr = vbound(value/10000,0,255);
26312 break;
26313 }
26314 case SAVEDPORTALDSTSCREEN:
26315 {
26316 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestScreen"))
26317 p->destscr = vbound(value/10000,0,255);
26318 break;
26319 }
26320 case SAVEDPORTALWARPSFX:
26321 {
26322 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpSFX"))
26323 p->sfx = vbound(value/10000,0,255);
26324 break;
26325 }
26326 case SAVEDPORTALWARPVFX:
26327 {
26328 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpEffect"))
26329 p->warpfx = vbound(value/10000,0,255);
26330 break;
26331 }
26332 case SAVEDPORTALSPRITE:
26333 {
26334 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Sprite"))
26335 p->spr = vbound(value/10000,0,255);
26336 break;
26337 }
26338 case SAVEDPORTALPORTAL:
26339 {
26340 if(ri->saveportalref < 0 || value < 0) break;
26341 if(savedportal* sp = checkSavedPortal(ri->saveportalref, "Portal"))
26342 {
26343 int32_t id = getPortalFromSaved(sp);
26344 if(id == value) break; //no change
26345 portal* p = checkPortal(value,"savedportal->Portal");
26346 if(p)
26347 {
26348 p->saved_data = sp->getUID();
26349 if(id > 0)
26350 {
26351 portal* p = checkPortal(id,"THIS SHOULD NOT APPEAR");
26352 p->saved_data = 0;
26353 }
26354 }
26355 }
26356 break;
26357 }
26358
26359 case GAMENUMASUB:
26360 {
26361 if(value >= 0)
26362 {
26363 size_t sz = vbound(value/10000, 0, 256);
26364 while(subscreens_active.size() < sz)
26365 {
26366 auto& sub = subscreens_active.emplace_back();
26367 sub.sub_type = sstACTIVE;
26368 }
26369 while(subscreens_active.size() > sz)
26370 subscreens_active.pop_back();
26371 }
26372 break;
26373 }
26374 case GAMENUMPSUB:
26375 {
26376 if(value >= 0)
26377 {
26378 size_t sz = vbound(value/10000, 0, 256);
26379 while(subscreens_passive.size() < sz)
26380 {
26381 auto& sub = subscreens_passive.emplace_back();
26382 sub.sub_type = sstPASSIVE;
26383 }
26384 while(subscreens_passive.size() > sz)
26385 subscreens_passive.pop_back();
26386 }
26387 break;
26388 }
26389 case GAMENUMOSUB:
26390 {
26391 if(value >= 0)
26392 {
26393 size_t sz = vbound(value/10000, 0, 256);
26394 while(subscreens_overlay.size() < sz)
26395 {
26396 auto& sub = subscreens_overlay.emplace_back();
26397 sub.sub_type = sstOVERLAY;
26398 }
26399 while(subscreens_overlay.size() > sz)
26400 subscreens_overlay.pop_back();
26401 }
26402 break;
26403 }
26404 ///----------------------------------------------------------------------------------------------------//
26405
26406 case SUBDATACURPG:
26407 {
26408 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "CurPage"))
26409 if(sub->sub_type == sstACTIVE)
26410 sub->curpage = vbound(value/10000,0,sub->pages.size()-1);
26411 break;
26412 }
26413 case SUBDATANUMPG:
26414 {
26415 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "NumPages"))
26416 if(sub->sub_type == sstACTIVE && value >= 10000)
26417 {
26418 size_t sz = value/10000;
26419 while(sub->pages.size() < sz)
26420 if(!sub->add_page(MAX_SUBSCR_PAGES))
26421 break;
26422 while(sub->pages.size() > sz)
26423 sub->delete_page(sub->pages.size()-1);
26424 }
26425 break;
26426 }
26427 case SUBDATAPAGES: break; //READONLY
26428 case SUBDATATYPE: break; //READONLY
26429 case SUBDATAFLAGS:
26430 {
26431 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "Flags[]"))
26432 {
26433 size_t indx = ri->d[rINDEX]/10000;
26434 size_t sz = 0;
26435 switch(sub->sub_type)
26436 {
26437 case sstACTIVE:
26438 sz = 2;
26439 break;
26440 case sstPASSIVE:
26441 sz = 0;
26442 break;
26443 case sstOVERLAY:
26444 sz = 0;
26445 break;
26446 }
26447 if(indx >= sz)
26448 {
26449 Z_scripterrlog("Bad index '%d' to array "
26450 "'subscreendata->Flags[]' of size '%d'\n", indx, sz);
26451 }
26452 else
26453 SETFLAG(sub->flags,(1<<indx),value);
26454 }
26455 break;
26456 }
26457 ///---- ACTIVE SUBSCREENS ONLY
26458 case SUBDATACURSORPOS:
26459 {
26460 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "CursorPos", sstACTIVE))
26461 {
26462 SubscrPage& pg = sub->cur_page();
26463 //Should this be sanity checked? Or should nulling out
26464 // the cursor by setting it invalid be allowed? -Em
26465 pg.cursor_pos = vbound(value/10000,0,255);
26466 }
26467 break;
26468 }
26469 case SUBDATASCRIPT:
26470 {
26471 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "Script", sstACTIVE))
26472 sub->script = vbound(value/10000,0,NUMSCRIPTSSUBSCREEN-1);
26473 break;
26474 }
26475 case SUBDATAINITD:
26476 {
26477 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "InitD[]", sstACTIVE))
26478 {
26479 size_t indx = ri->d[rINDEX]/10000;
26480 if(indx >= 8)
26481 {
26482 Z_scripterrlog("Bad index '%d' to array "
26483 "'subscreendata->InitD[8]'\n", indx);
26484 }
26485 else
26486 sub->initd[indx] = value;
26487 }
26488 break;
26489 }
26490 case SUBDATABTNLEFT:
26491 {
26492 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "BtnPageLeft[]", sstACTIVE))
26493 {
26494 size_t indx = ri->d[rINDEX]/10000;
26495 if(indx >= 8)
26496 {
26497 Z_scripterrlog("Bad index '%d' to array "
26498 "'subscreendata->BtnPageLeft[8]'\n", indx);
26499 }
26500 else
26501 SETFLAG(sub->btn_left,(1<<indx),value);
26502 }
26503 break;
26504 }
26505 case SUBDATABTNRIGHT:
26506 {
26507 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "BtnPageRight[]", sstACTIVE))
26508 {
26509 size_t indx = ri->d[rINDEX]/10000;
26510 if(indx >= 8)
26511 {
26512 Z_scripterrlog("Bad index '%d' to array "
26513 "'subscreendata->BtnPageRight[8]'\n", indx);
26514 }
26515 else
26516 SETFLAG(sub->btn_right,(1<<indx),value);
26517 }
26518 break;
26519 }
26520 case SUBDATATRANSLEFTTY:
26521 {
26522 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftType", sstACTIVE))
26523 {
26524 auto& trans = sub->trans_left;
26525 trans.type = vbound(value/10000,0,sstrMAX-1);
26526 }
26527 break;
26528 }
26529 case SUBDATATRANSLEFTSFX:
26530 {
26531 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftSFX", sstACTIVE))
26532 {
26533 auto& trans = sub->trans_left;
26534 trans.tr_sfx = vbound(value/10000,0,255);
26535 }
26536 break;
26537 }
26538 case SUBDATATRANSLEFTFLAGS:
26539 {
26540 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftFlags[]", sstACTIVE))
26541 {
26542 auto& trans = sub->trans_left;
26543 size_t indx = ri->d[rINDEX]/10000;
26544 if(indx >= SUBSCR_TRANS_NUMFLAGS)
26545 {
26546 Z_scripterrlog("Bad index '%d' to array "
26547 "'subscreendata->TransLeftFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
26548 }
26549 else
26550 SETFLAG(trans.flags,(1<<indx),value);
26551 }
26552 break;
26553 }
26554 case SUBDATATRANSLEFTARGS:
26555 {
26556 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftArgs[]", sstACTIVE))
26557 {
26558 auto& trans = sub->trans_left;
26559 size_t indx = ri->d[rINDEX]/10000;
26560 if(indx >= SUBSCR_TRANSITION_MAXARG)
26561 {
26562 Z_scripterrlog("Bad index '%d' to array "
26563 "'subscreendata->TransLeftArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
26564 }
26565 else
26566 trans.arg[indx] = value/SubscrTransition::argScale(trans.type,indx);
26567 }
26568 break;
26569 }
26570 case SUBDATATRANSRIGHTTY:
26571 {
26572 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightType", sstACTIVE))
26573 {
26574 auto& trans = sub->trans_right;
26575 trans.type = vbound(value/10000,0,sstrMAX-1);
26576 }
26577 break;
26578 }
26579 case SUBDATATRANSRIGHTSFX:
26580 {
26581 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightSFX", sstACTIVE))
26582 {
26583 auto& trans = sub->trans_right;
26584 trans.tr_sfx = vbound(value/10000,0,255);
26585 }
26586 break;
26587 }
26588 case SUBDATATRANSRIGHTFLAGS:
26589 {
26590 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightFlags[]", sstACTIVE))
26591 {
26592 auto& trans = sub->trans_right;
26593 size_t indx = ri->d[rINDEX]/10000;
26594 if(indx >= SUBSCR_TRANS_NUMFLAGS)
26595 {
26596 Z_scripterrlog("Bad index '%d' to array "
26597 "'subscreendata->TransRightFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
26598 }
26599 else
26600 SETFLAG(trans.flags,(1<<indx),value);
26601 }
26602 break;
26603 }
26604 case SUBDATATRANSRIGHTARGS:
26605 {
26606 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightArgs[]", sstACTIVE))
26607 {
26608 auto& trans = sub->trans_right;
26609 size_t indx = ri->d[rINDEX]/10000;
26610 if(indx >= SUBSCR_TRANSITION_MAXARG)
26611 {
26612 Z_scripterrlog("Bad index '%d' to array "
26613 "'subscreendata->TransRightArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
26614 }
26615 else
26616 trans.arg[indx] = value/SubscrTransition::argScale(trans.type,indx);
26617 }
26618 break;
26619 }
26620 case SUBDATASELECTORDSTX:
26621 {
26622 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestX", sstACTIVE))
26623 sub->selector_setting.x = vbound(value/10000,-32768,32767);
26624 break;
26625 }
26626 case SUBDATASELECTORDSTY:
26627 {
26628 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestY", sstACTIVE))
26629 sub->selector_setting.y = vbound(value/10000,-32768,32767);
26630 break;
26631 }
26632 case SUBDATASELECTORDSTW:
26633 {
26634 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestW", sstACTIVE))
26635 sub->selector_setting.w = vbound(value/10000,-32768,32767);
26636 break;
26637 }
26638 case SUBDATASELECTORDSTH:
26639 {
26640 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestH", sstACTIVE))
26641 sub->selector_setting.h = vbound(value/10000,-32768,32767);
26642 break;
26643 }
26644 case SUBDATASELECTORWID:
26645 {
26646 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestWid", sstACTIVE))
26647 {
26648 size_t indx = ri->d[rINDEX]/10000;
26649 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26650 {
26651 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26652 "SelectorDestWid[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26653 }
26654 else
26655 sub->selector_setting.tileinfo[indx].sw = vbound(value/10000,0,65535);
26656 }
26657 break;
26658 }
26659 case SUBDATASELECTORHEI:
26660 {
26661 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestHei", sstACTIVE))
26662 {
26663 size_t indx = ri->d[rINDEX]/10000;
26664 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26665 {
26666 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26667 "SelectorDestHei[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26668 }
26669 else
26670 sub->selector_setting.tileinfo[indx].sh = vbound(value/10000,0,65535);
26671 }
26672 break;
26673 }
26674 case SUBDATASELECTORTILE:
26675 {
26676 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorTile", sstACTIVE))
26677 {
26678 size_t indx = ri->d[rINDEX]/10000;
26679 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26680 {
26681 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26682 "SelectorTile[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26683 }
26684 else
26685 sub->selector_setting.tileinfo[indx].tile = vbound(value/10000,0,NEWMAXTILES-1);
26686 }
26687 break;
26688 }
26689 case SUBDATASELECTORCSET:
26690 {
26691 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorCSet", sstACTIVE))
26692 {
26693 size_t indx = ri->d[rINDEX]/10000;
26694 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26695 {
26696 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26697 "SelectorCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26698 }
26699 else
26700 {
26701 byte& cs = sub->selector_setting.tileinfo[indx].cset;
26702 cs = (cs&0xF0)|vbound(value/10000,0,0x0F);
26703 }
26704 }
26705 break;
26706 }
26707 case SUBDATASELECTORFLASHCSET:
26708 {
26709 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorFlashCSet", sstACTIVE))
26710 {
26711 size_t indx = ri->d[rINDEX]/10000;
26712 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26713 {
26714 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26715 "SelectorFlashCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26716 }
26717 else
26718 {
26719 byte& cs = sub->selector_setting.tileinfo[indx].cset;
26720 cs = (cs&0x0F)|(vbound(value/10000,0,0x0F)<<4);
26721 }
26722 }
26723 break;
26724 }
26725 case SUBDATASELECTORFRM:
26726 {
26727 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorFrames", sstACTIVE))
26728 {
26729 size_t indx = ri->d[rINDEX]/10000;
26730 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26731 {
26732 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26733 "SelectorFrames[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26734 }
26735 else
26736 sub->selector_setting.tileinfo[indx].frames = vbound(value/10000,1,255);
26737 }
26738 break;
26739 }
26740 case SUBDATASELECTORASPD:
26741 {
26742 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorASpeed", sstACTIVE))
26743 {
26744 size_t indx = ri->d[rINDEX]/10000;
26745 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26746 {
26747 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26748 "SelectorASpeed[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26749 }
26750 else
26751 sub->selector_setting.tileinfo[indx].speed = vbound(value/10000,1,255);
26752 }
26753 break;
26754 }
26755 case SUBDATASELECTORDELAY:
26756 {
26757 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDelay", sstACTIVE))
26758 {
26759 size_t indx = ri->d[rINDEX]/10000;
26760 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26761 {
26762 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26763 "SelectorDelay[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26764 }
26765 else
26766 sub->selector_setting.tileinfo[indx].delay = vbound(value/10000,0,255);
26767 }
26768 break;
26769 }
26770 ///---- CURRENTLY OPEN ACTIVE SUBSCREEN ONLY
26771 case SUBDATATRANSCLK:
26772 {
26773 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransClock", sstACTIVE))
26774 {
26775 if(sub != new_subscreen_active)
26776 Z_scripterrlog("'subscreendata->TransClock' is only"
26777 " valid for the current active subscreen!\n");
26778 else if(subscreen_open)
26779 {
26780 int val = value/10000;
26781 if(val < 0)
26782 subscrpg_clear_animation();
26783 else if(!subscr_pg_animating)
26784 {
26785 SubscrTransition tr = subscr_pg_transition;
26786 tr.tr_sfx = 0;
26787 subscrpg_animate(subscr_pg_from,subscr_pg_to,tr,*new_subscreen_active);
26788 subscr_pg_clk = val;
26789 }
26790 else subscr_pg_clk = val;
26791 }
26792 }
26793 break;
26794 }
26795 case SUBDATATRANSTY:
26796 {
26797 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransType", sstACTIVE))
26798 {
26799 auto& trans = subscr_pg_transition;
26800 if(sub != new_subscreen_active)
26801 Z_scripterrlog("'subscreendata->TransType' is only"
26802 " valid for the current active subscreen!\n");
26803 else if(subscreen_open)
26804 trans.type = vbound(value/10000,0,sstrMAX-1);
26805 }
26806 break;
26807 }
26808 case SUBDATATRANSFLAGS:
26809 {
26810 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransFlags[]", sstACTIVE))
26811 {
26812 auto& trans = subscr_pg_transition;
26813 size_t indx = ri->d[rINDEX]/10000;
26814 if(indx >= SUBSCR_TRANS_NUMFLAGS)
26815 {
26816 Z_scripterrlog("Bad index '%d' to array "
26817 "'subscreendata->TransFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
26818 }
26819 else if(sub != new_subscreen_active)
26820 Z_scripterrlog("'subscreendata->TransType' is only"
26821 " valid for the current active subscreen!\n");
26822 else if(subscreen_open)
26823 SETFLAG(trans.flags,(1<<indx),value);
26824 }
26825 break;
26826 }
26827 case SUBDATATRANSARGS:
26828 {
26829 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransArgs[]", sstACTIVE))
26830 {
26831 auto& trans = subscr_pg_transition;
26832 size_t indx = ri->d[rINDEX]/10000;
26833 if(indx >= SUBSCR_TRANSITION_MAXARG)
26834 {
26835 Z_scripterrlog("Bad index '%d' to array "
26836 "'subscreendata->TransArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
26837 }
26838 else if(sub != new_subscreen_active)
26839 Z_scripterrlog("'subscreendata->TransType' is only"
26840 " valid for the current active subscreen!\n");
26841 else if(subscreen_open)
26842 trans.arg[indx] = value/SubscrTransition::argScale(trans.type,indx);
26843 }
26844 break;
26845 }
26846 case SUBDATATRANSFROMPG:
26847 {
26848 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransFromPage", sstACTIVE))
26849 {
26850 if(sub != new_subscreen_active)
26851 Z_scripterrlog("'subscreendata->TransFromPage' is only"
26852 " valid for the current active subscreen!\n");
26853 else if(subscreen_open)
26854 subscr_pg_from = vbound(value/10000,0,sub->pages.size()-1);
26855 }
26856 break;
26857 }
26858 case SUBDATATRANSTOPG:
26859 {
26860 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransToPage", sstACTIVE))
26861 {
26862 if(sub != new_subscreen_active)
26863 Z_scripterrlog("'subscreendata->TransToPage' is only"
26864 " valid for the current active subscreen!\n");
26865 else if(subscreen_open)
26866 subscr_pg_to = vbound(value/10000,0,sub->pages.size()-1);
26867 }
26868 break;
26869 }
26870
26871 ///----------------------------------------------------------------------------------------------------//
26872 case SUBPGINDEX: break; //READ-ONLY
26873 case SUBPGNUMWIDG: break; //READ-ONLY
26874 case SUBPGWIDGETS: break; //READ-ONLY
26875 case SUBPGSUBDATA: break; //READ-ONLY
26876 case SUBPGCURSORPOS:
26877 {
26878 if(SubscrPage* pg = checkSubPage(ri->subpageref, "CursorPos"))
26879 pg->cursor_pos = vbound(value/10000,0,255);
26880 break;
26881 }
26882 ///----------------------------------------------------------------------------------------------------//
26883 ///---- ANY WIDGET TYPE
26884 case SUBWIDGTYPE: break; //READ-ONLY
26885 case SUBWIDGINDEX: break; //READ-ONLY
26886 case SUBWIDGPAGE: break; //READ-ONLY
26887 case SUBWIDGDISPITM: break; //READ-ONLY
26888 case SUBWIDGEQPITM: break; //READ-ONLY
26889 case SUBWIDGPOS:
26890 {
26891 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Pos"))
26892 widg->pos = vbound(value/10000,0,255);
26893 break;
26894 }
26895 case SUBWIDGPOSES:
26896 {
26897 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PosDirs"))
26898 {
26899 size_t indx = ri->d[rINDEX]/10000;
26900 if(indx >= 4)
26901 {
26902 Z_scripterrlog("Bad index '%d' to array "
26903 "'subscreenwidget->PosDirs[%d]'\n", indx, 4);
26904 }
26905 else
26906 {
26907 byte val = vbound(value/10000,0,255);
26908 switch(indx)
26909 {
26910 case up:
26911 widg->pos_up = val;
26912 break;
26913 case down:
26914 widg->pos_down = val;
26915 break;
26916 case left:
26917 widg->pos_left = val;
26918 break;
26919 case right:
26920 widg->pos_right = val;
26921 break;
26922 }
26923 }
26924 }
26925 break;
26926 }
26927 case SUBWIDGPOSFLAG:
26928 {
26929 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "VisibleFlags"))
26930 {
26931 size_t indx = ri->d[rINDEX]/10000;
26932 if(indx >= sspNUM)
26933 {
26934 Z_scripterrlog("Bad index '%d' to array "
26935 "'subscreenwidget->VisibleFlags[%d]'\n", indx, sspNUM);
26936 }
26937 else
26938 {
26939 SETFLAG(widg->posflags, 1<<indx, value);
26940 }
26941 }
26942 break;
26943 }
26944 case SUBWIDGX:
26945 {
26946 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "X"))
26947 widg->x = vbound(value/10000,-32768,32767);
26948 break;
26949 }
26950 case SUBWIDGY:
26951 {
26952 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Y"))
26953 widg->y = vbound(value/10000,-32768,32767);
26954 break;
26955 }
26956 case SUBWIDGW:
26957 {
26958 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "W"))
26959 widg->w = vbound(value/10000,0,65535);
26960 break;
26961 }
26962 case SUBWIDGH:
26963 {
26964 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "H"))
26965 widg->h = vbound(value/10000,0,65535);
26966 break;
26967 }
26968 case SUBWIDGGENFLAG:
26969 {
26970 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GenFlags"))
26971 {
26972 size_t indx = ri->d[rINDEX]/10000;
26973 if(indx >= SUBSCRFLAG_GEN_COUNT)
26974 {
26975 Z_scripterrlog("Bad index '%d' to array "
26976 "'subscreenwidget->GenFlags[%d]'\n", indx, SUBSCRFLAG_GEN_COUNT);
26977 }
26978 else
26979 {
26980 SETFLAG(widg->genflags, 1<<indx, value);
26981 }
26982 }
26983 break;
26984 }
26985 case SUBWIDGFLAG:
26986 {
26987 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Flags"))
26988 {
26989 size_t indx = ri->d[rINDEX]/10000;
26990 byte sz = widg->numFlags();
26991 if(indx >= sz)
26992 {
26993 Z_scripterrlog("Bad index '%d' to array "
26994 "'subscreenwidget->Flags[%d]'\n", indx, sz);
26995 }
26996 else
26997 {
26998 SETFLAG(widg->flags, 1<<indx, value);
26999 }
27000 }
27001 break;
27002 }
27003 ///---- ACTIVE SUBSCREENS ONLY
27004 case SUBWIDGSELECTORDSTX:
27005 {
27006 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestX", sstACTIVE))
27007 widg->selector_override.x = vbound(value/10000,-32768,32767);
27008 break;
27009 }
27010 case SUBWIDGSELECTORDSTY:
27011 {
27012 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestY", sstACTIVE))
27013 widg->selector_override.y = vbound(value/10000,-32768,32767);
27014 break;
27015 }
27016 case SUBWIDGSELECTORDSTW:
27017 {
27018 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestW", sstACTIVE))
27019 widg->selector_override.w = vbound(value/10000,-32768,32767);
27020 break;
27021 }
27022 case SUBWIDGSELECTORDSTH:
27023 {
27024 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestH", sstACTIVE))
27025 widg->selector_override.h = vbound(value/10000,-32768,32767);
27026 break;
27027 }
27028 case SUBWIDGSELECTORWID:
27029 {
27030 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestWid", sstACTIVE))
27031 {
27032 size_t indx = ri->d[rINDEX]/10000;
27033 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
27034 {
27035 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
27036 "SelectorDestWid[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
27037 }
27038 else
27039 widg->selector_override.tileinfo[indx].sw = vbound(value/10000,0,65535);
27040 }
27041 break;
27042 }
27043 case SUBWIDGSELECTORHEI:
27044 {
27045 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestHei", sstACTIVE))
27046 {
27047 size_t indx = ri->d[rINDEX]/10000;
27048 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
27049 {
27050 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
27051 "SelectorDestHei[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
27052 }
27053 else
27054 widg->selector_override.tileinfo[indx].sh = vbound(value/10000,0,65535);
27055 }
27056 break;
27057 }
27058 case SUBWIDGSELECTORTILE:
27059 {
27060 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorTile", sstACTIVE))
27061 {
27062 size_t indx = ri->d[rINDEX]/10000;
27063 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
27064 {
27065 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
27066 "SelectorTile[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
27067 }
27068 else
27069 widg->selector_override.tileinfo[indx].tile = vbound(value/10000,0,NEWMAXTILES-1);
27070 }
27071 break;
27072 }
27073 case SUBWIDGSELECTORCSET:
27074 {
27075 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorCSet", sstACTIVE))
27076 {
27077 size_t indx = ri->d[rINDEX]/10000;
27078 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
27079 {
27080 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
27081 "SelectorCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
27082 }
27083 else
27084 {
27085 byte& cs = widg->selector_override.tileinfo[indx].cset;
27086 cs = (cs&0xF0)|vbound(value/10000,0,0x0F);
27087 }
27088 }
27089 break;
27090 }
27091 case SUBWIDGSELECTORFLASHCSET:
27092 {
27093 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorFlashCSet", sstACTIVE))
27094 {
27095 size_t indx = ri->d[rINDEX]/10000;
27096 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
27097 {
27098 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
27099 "SelectorFlashCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
27100 }
27101 else
27102 {
27103 byte& cs = widg->selector_override.tileinfo[indx].cset;
27104 cs = (cs&0x0F)|(vbound(value/10000,0,0x0F)<<4);
27105 }
27106 }
27107 break;
27108 }
27109 case SUBWIDGSELECTORFRM:
27110 {
27111 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorFrames", sstACTIVE))
27112 {
27113 size_t indx = ri->d[rINDEX]/10000;
27114 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
27115 {
27116 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
27117 "SelectorFrames[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
27118 }
27119 else
27120 widg->selector_override.tileinfo[indx].frames = vbound(value/10000,1,255);
27121 }
27122 break;
27123 }
27124 case SUBWIDGSELECTORASPD:
27125 {
27126 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorASpeed", sstACTIVE))
27127 {
27128 size_t indx = ri->d[rINDEX]/10000;
27129 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
27130 {
27131 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
27132 "SelectorASpeed[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
27133 }
27134 else
27135 widg->selector_override.tileinfo[indx].speed = vbound(value/10000,1,255);
27136 }
27137 break;
27138 }
27139 case SUBWIDGSELECTORDELAY:
27140 {
27141 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDelay", sstACTIVE))
27142 {
27143 size_t indx = ri->d[rINDEX]/10000;
27144 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
27145 {
27146 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
27147 "SelectorDelay[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
27148 }
27149 else
27150 widg->selector_override.tileinfo[indx].delay = vbound(value/10000,0,255);
27151 }
27152 break;
27153 }
27154
27155 case SUBWIDGPRESSSCRIPT:
27156 {
27157 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PressScript", sstACTIVE))
27158 widg->generic_script = vbound(value/10000,0,NUMSCRIPTSGENERIC-1);
27159 break;
27160 }
27161 case SUBWIDGPRESSINITD:
27162 {
27163 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PressInitD[]", sstACTIVE))
27164 {
27165 size_t indx = ri->d[rINDEX]/10000;
27166 if(indx >= 8)
27167 {
27168 Z_scripterrlog("Bad index '%d' to array "
27169 "'subscreenwidget->PressInitD[8]'\n", indx);
27170 }
27171 else
27172 widg->generic_initd[indx] = value;
27173 }
27174 break;
27175 }
27176 case SUBWIDGBTNPRESS:
27177 {
27178 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "BtnPressScript[]", sstACTIVE))
27179 {
27180 size_t indx = ri->d[rINDEX]/10000;
27181 if(indx >= 8)
27182 {
27183 Z_scripterrlog("Bad index '%d' to array "
27184 "'subscreenwidget->BtnPressScript[8]'\n", indx);
27185 }
27186 else
27187 SETFLAG(widg->gen_script_btns,(1<<indx),value);
27188 }
27189 break;
27190 }
27191 case SUBWIDGBTNPG:
27192 {
27193 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "BtnPageChange[]", sstACTIVE))
27194 {
27195 size_t indx = ri->d[rINDEX]/10000;
27196 if(indx >= 8)
27197 {
27198 Z_scripterrlog("Bad index '%d' to array "
27199 "'subscreenwidget->BtnPageChange[8]'\n", indx);
27200 }
27201 else
27202 SETFLAG(widg->pg_btns,(1<<indx),value);
27203 }
27204 break;
27205 }
27206 case SUBWIDGPGMODE:
27207 {
27208 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageMode", sstACTIVE))
27209 widg->pg_mode = vbound(value/10000,0,PGGOTO_MAX-1);
27210 break;
27211 }
27212 case SUBWIDGPGTARG:
27213 {
27214 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "TargetPage", sstACTIVE))
27215 widg->pg_targ = vbound(value/10000,0,MAX_SUBSCR_PAGES-1);
27216 break;
27217 }
27218
27219 case SUBWIDGTRANSPGTY:
27220 {
27221 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransType", sstACTIVE))
27222 {
27223 auto& trans = widg->pg_trans;
27224 trans.type = vbound(value/10000,0,sstrMAX-1);
27225 }
27226 break;
27227 }
27228 case SUBWIDGTRANSPGSFX:
27229 {
27230 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransSFX", sstACTIVE))
27231 {
27232 auto& trans = widg->pg_trans;
27233 trans.tr_sfx = vbound(value/10000,0,255);
27234 }
27235 break;
27236 }
27237 case SUBWIDGTRANSPGFLAGS:
27238 {
27239 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransFlags[]", sstACTIVE))
27240 {
27241 auto& trans = widg->pg_trans;
27242 size_t indx = ri->d[rINDEX]/10000;
27243 if(indx >= SUBSCR_TRANS_NUMFLAGS)
27244 {
27245 Z_scripterrlog("Bad index '%d' to array "
27246 "'subscreenwidget->PageTransFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
27247 }
27248 else
27249 SETFLAG(trans.flags,(1<<indx),value);
27250 }
27251 break;
27252 }
27253 case SUBWIDGTRANSPGARGS:
27254 {
27255 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransArgs[]", sstACTIVE))
27256 {
27257 auto& trans = widg->pg_trans;
27258 size_t indx = ri->d[rINDEX]/10000;
27259 if(indx >= SUBSCR_TRANSITION_MAXARG)
27260 {
27261 Z_scripterrlog("Bad index '%d' to array "
27262 "'subscreenwidget->PageTransArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
27263 }
27264 else
27265 trans.arg[indx] = value/SubscrTransition::argScale(trans.type,indx);
27266 }
27267 break;
27268 }
27269 ///---- VARYING WIDGET TYPES
27270 case SUBWIDGTY_CSET:
27271 {
27272 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "CSet"))
27273 {
27274 auto val = vbound(value/10000,-sscsMAX,15);
27275 size_t indx = ri->d[rINDEX]/10000;
27276 size_t sz = 0;
27277 byte ty = widg->getType();
27278 switch(ty)
27279 {
27280 case widgFRAME:
27281 case widgMCGUFF:
27282 case widgTILEBLOCK:
27283 case widgMINITILE:
27284 sz = 1;
27285 break;
27286 case widgLGAUGE:
27287 case widgMGAUGE:
27288 case widgMISCGAUGE:
27289 sz = 4;
27290 break;
27291 default:
27292 sz = 0;
27293 bad_subwidg_type("CSet[]", false, ty);
27294 break;
27295 }
27296 if(!sz) break;
27297 if(indx >= sz)
27298 {
27299 Z_scripterrlog("Bad index '%d' to array "
27300 "'subscreenwidget->CSet[%d]'\n", indx, sz);
27301 break;
27302 }
27303 switch(ty)
27304 {
27305 case widgFRAME:
27306 ((SW_2x2Frame*)widg)->cs.set_int_cset(val);
27307 break;
27308 case widgMCGUFF:
27309 ((SW_McGuffin*)widg)->cs.set_int_cset(val);
27310 break;
27311 case widgTILEBLOCK:
27312 ((SW_TileBlock*)widg)->cs.set_int_cset(val);
27313 break;
27314 case widgMINITILE:
27315 ((SW_MiniTile*)widg)->cs.set_int_cset(val);
27316 break;
27317 case widgLGAUGE:
27318 case widgMGAUGE:
27319 case widgMISCGAUGE:
27320 val = vbound(value/10000,0,15);
27321 ((SW_GaugePiece*)widg)->mts[indx].cset = val;
27322 break;
27323 }
27324 }
27325 break;
27326 }
27327 case SUBWIDGTY_TILE:
27328 {
27329 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Tile[]"))
27330 {
27331 auto val = vbound(value/10000,0,NEWMAXTILES-1);
27332 size_t indx = ri->d[rINDEX]/10000;
27333 size_t sz = 0;
27334 byte ty = widg->getType();
27335 switch(ty)
27336 {
27337 case widgFRAME:
27338 case widgMCGUFF:
27339 case widgTILEBLOCK:
27340 case widgMINITILE:
27341 sz = 1;
27342 break;
27343 case widgLGAUGE:
27344 case widgMGAUGE:
27345 case widgMISCGAUGE:
27346 sz = 4;
27347 break;
27348 default:
27349 sz = 0;
27350 bad_subwidg_type("Tile[]", false, ty);
27351 break;
27352 }
27353 if(!sz) break;
27354 if(indx >= sz)
27355 {
27356 Z_scripterrlog("Bad index '%d' to array "
27357 "'subscreenwidget->Tile[%d]'\n", indx, sz);
27358 break;
27359 }
27360 switch(ty)
27361 {
27362 case widgFRAME:
27363 ((SW_2x2Frame*)widg)->tile = val;
27364 break;
27365 case widgMCGUFF:
27366 ((SW_McGuffin*)widg)->tile = val;
27367 break;
27368 case widgTILEBLOCK:
27369 ((SW_TileBlock*)widg)->tile = val;
27370 break;
27371 case widgMINITILE:
27372 val = vbound(value/10000,-ssmstMAX,NEWMAXTILES-1);
27373 ((SW_MiniTile*)widg)->set_int_tile(val);
27374 break;
27375 case widgLGAUGE:
27376 case widgMGAUGE:
27377 case widgMISCGAUGE:
27378 ((SW_GaugePiece*)widg)->mts[indx].setTile(val);
27379 break;
27380 }
27381 }
27382 break;
27383 }
27384 case SUBWIDGTY_FONT:
27385 {
27386 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Font"))
27387 {
27388 auto val = vbound(value/10000,0,font_max-1);
27389 auto ty = widg->getType();
27390 switch(ty)
27391 {
27392 case widgTEXT:
27393 ((SW_Text*)widg)->fontid = val;
27394 break;
27395 case widgTEXTBOX:
27396 ((SW_TextBox*)widg)->fontid = val;
27397 break;
27398 case widgSELECTEDTEXT:
27399 ((SW_SelectedText*)widg)->fontid = val;
27400 break;
27401 case widgTIME:
27402 ((SW_Time*)widg)->fontid = val;
27403 break;
27404 case widgCOUNTER:
27405 ((SW_Counter*)widg)->fontid = val;
27406 break;
27407 case widgBTNCOUNTER:
27408 ((SW_BtnCounter*)widg)->fontid = val;
27409 break;
27410 case widgOLDCTR:
27411 ((SW_Counters*)widg)->fontid = val;
27412 break;
27413 case widgMMAPTITLE:
27414 ((SW_MMapTitle*)widg)->fontid = val;
27415 break;
27416 default:
27417 bad_subwidg_type("Font", false, ty);
27418 break;
27419 }
27420 }
27421 break;
27422 }
27423 case SUBWIDGTY_ALIGN:
27424 {
27425 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Align"))
27426 {
27427 auto val = vbound(value/10000,0,sstaMAX-1);
27428 auto ty = widg->getType();
27429 switch(ty)
27430 {
27431 case widgTEXT:
27432 ((SW_Text*)widg)->align = val;
27433 break;
27434 case widgTEXTBOX:
27435 ((SW_TextBox*)widg)->align = val;
27436 break;
27437 case widgSELECTEDTEXT:
27438 ((SW_SelectedText*)widg)->align = val;
27439 break;
27440 case widgTIME:
27441 ((SW_Time*)widg)->align = val;
27442 break;
27443 case widgCOUNTER:
27444 ((SW_Counter*)widg)->align = val;
27445 break;
27446 case widgBTNCOUNTER:
27447 ((SW_BtnCounter*)widg)->align = val;
27448 break;
27449 case widgMMAPTITLE:
27450 ((SW_MMapTitle*)widg)->align = val;
27451 break;
27452 default:
27453 bad_subwidg_type("Align", false, ty);
27454 break;
27455 }
27456 }
27457 break;
27458 }
27459 case SUBWIDGTY_SHADOWTY:
27460 {
27461 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ShadowType"))
27462 {
27463 auto val = vbound(value/10000,0,sstsMAX-1);
27464 auto ty = widg->getType();
27465 switch(ty)
27466 {
27467 case widgTEXT:
27468 ((SW_Text*)widg)->shadtype = val;
27469 break;
27470 case widgTEXTBOX:
27471 ((SW_TextBox*)widg)->shadtype = val;
27472 break;
27473 case widgSELECTEDTEXT:
27474 ((SW_SelectedText*)widg)->shadtype = val;
27475 break;
27476 case widgTIME:
27477 ((SW_Time*)widg)->shadtype = val;
27478 break;
27479 case widgCOUNTER:
27480 ((SW_Counter*)widg)->shadtype = val;
27481 break;
27482 case widgBTNCOUNTER:
27483 ((SW_BtnCounter*)widg)->shadtype = val;
27484 break;
27485 case widgOLDCTR:
27486 ((SW_Counters*)widg)->shadtype = val;
27487 break;
27488 case widgMMAPTITLE:
27489 ((SW_MMapTitle*)widg)->shadtype = val;
27490 break;
27491 default:
27492 bad_subwidg_type("ShadowType", false, ty);
27493 break;
27494 }
27495 }
27496 break;
27497 }
27498 case SUBWIDGTY_COLOR_TXT:
27499 {
27500 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorText"))
27501 {
27502 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27503 auto ty = widg->getType();
27504 switch(ty)
27505 {
27506 case widgTEXT:
27507 ((SW_Text*)widg)->c_text.set_int_color(val);
27508 break;
27509 case widgTEXTBOX:
27510 ((SW_TextBox*)widg)->c_text.set_int_color(val);
27511 break;
27512 case widgSELECTEDTEXT:
27513 ((SW_SelectedText*)widg)->c_text.set_int_color(val);
27514 break;
27515 case widgTIME:
27516 ((SW_Time*)widg)->c_text.set_int_color(val);
27517 break;
27518 case widgCOUNTER:
27519 ((SW_Counter*)widg)->c_text.set_int_color(val);
27520 break;
27521 case widgBTNCOUNTER:
27522 ((SW_BtnCounter*)widg)->c_text.set_int_color(val);
27523 break;
27524 case widgOLDCTR:
27525 ((SW_Counters*)widg)->c_text.set_int_color(val);
27526 break;
27527 case widgMMAPTITLE:
27528 ((SW_MMapTitle*)widg)->c_text.set_int_color(val);
27529 break;
27530 case widgMCGUFF_FRAME:
27531 ((SW_TriFrame*)widg)->c_number.set_int_color(val);
27532 break;
27533 default:
27534 bad_subwidg_type("ColorText", false, ty);
27535 break;
27536 }
27537 }
27538 break;
27539 }
27540 case SUBWIDGTY_COLOR_SHD:
27541 {
27542 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorShadow"))
27543 {
27544 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27545 auto ty = widg->getType();
27546 switch(ty)
27547 {
27548 case widgTEXT:
27549 ((SW_Text*)widg)->c_shadow.set_int_color(val);
27550 break;
27551 case widgTEXTBOX:
27552 ((SW_TextBox*)widg)->c_shadow.set_int_color(val);
27553 break;
27554 case widgSELECTEDTEXT:
27555 ((SW_SelectedText*)widg)->c_shadow.set_int_color(val);
27556 break;
27557 case widgTIME:
27558 ((SW_Time*)widg)->c_shadow.set_int_color(val);
27559 break;
27560 case widgCOUNTER:
27561 ((SW_Counter*)widg)->c_shadow.set_int_color(val);
27562 break;
27563 case widgBTNCOUNTER:
27564 ((SW_BtnCounter*)widg)->c_shadow.set_int_color(val);
27565 break;
27566 case widgOLDCTR:
27567 ((SW_Counters*)widg)->c_shadow.set_int_color(val);
27568 break;
27569 case widgMMAPTITLE:
27570 ((SW_MMapTitle*)widg)->c_shadow.set_int_color(val);
27571 break;
27572 default:
27573 bad_subwidg_type("ColorShadow", false, ty);
27574 break;
27575 }
27576 }
27577 break;
27578 }
27579 case SUBWIDGTY_COLOR_BG:
27580 {
27581 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorBG"))
27582 {
27583 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27584 auto ty = widg->getType();
27585 switch(ty)
27586 {
27587 case widgTEXT:
27588 ((SW_Text*)widg)->c_bg.set_int_color(val);
27589 break;
27590 case widgTEXTBOX:
27591 ((SW_TextBox*)widg)->c_bg.set_int_color(val);;
27592 break;
27593 case widgSELECTEDTEXT:
27594 ((SW_SelectedText*)widg)->c_bg.set_int_color(val);;
27595 break;
27596 case widgTIME:
27597 ((SW_Time*)widg)->c_bg.set_int_color(val);
27598 break;
27599 case widgCOUNTER:
27600 ((SW_Counter*)widg)->c_bg.set_int_color(val);
27601 break;
27602 case widgBTNCOUNTER:
27603 ((SW_BtnCounter*)widg)->c_bg.set_int_color(val);
27604 break;
27605 case widgOLDCTR:
27606 ((SW_Counters*)widg)->c_bg.set_int_color(val);
27607 break;
27608 case widgMMAPTITLE:
27609 ((SW_MMapTitle*)widg)->c_bg.set_int_color(val);
27610 break;
27611 case widgBGCOLOR:
27612 ((SW_Clear*)widg)->c_bg.set_int_color(val);
27613 break;
27614 default:
27615 bad_subwidg_type("ColorBG", false, ty);
27616 break;
27617 }
27618 }
27619 break;
27620 }
27621
27622 case SUBWIDGTY_COLOR_OLINE:
27623 {
27624 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorOutline"))
27625 {
27626 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27627 auto ty = widg->getType();
27628 switch(ty)
27629 {
27630 case widgLINE:
27631 ((SW_Line*)widg)->c_line.set_int_color(val);
27632 break;
27633 case widgRECT:
27634 ((SW_Rect*)widg)->c_outline.set_int_color(val);
27635 break;
27636 case widgMCGUFF_FRAME:
27637 ((SW_TriFrame*)widg)->c_outline.set_int_color(val);
27638 break;
27639 default:
27640 bad_subwidg_type("ColorOutline", false, ty);
27641 break;
27642 }
27643 }
27644 break;
27645 }
27646
27647 case SUBWIDGTY_COLOR_FILL:
27648 {
27649 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorFill"))
27650 {
27651 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27652 auto ty = widg->getType();
27653 switch(ty)
27654 {
27655 case widgRECT:
27656 ((SW_Rect*)widg)->c_fill.set_int_color(val);
27657 break;
27658 default:
27659 bad_subwidg_type("ColorFill", false, ty);
27660 break;
27661 }
27662 }
27663 break;
27664 }
27665 case SUBWIDGTY_BUTTON:
27666 {
27667 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Button"))
27668 {
27669 auto val = vbound(value/10000,0,3);
27670 auto ty = widg->getType();
27671 switch(ty)
27672 {
27673 case widgBTNITM:
27674 ((SW_ButtonItem*)widg)->btn = val;
27675 break;
27676 case widgBTNCOUNTER:
27677 ((SW_BtnCounter*)widg)->btn = val;
27678 break;
27679 default:
27680 bad_subwidg_type("Button", false, ty);
27681 break;
27682 }
27683 }
27684 break;
27685 }
27686 case SUBWIDGTY_COUNTERS:
27687 {
27688 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Counter[]"))
27689 {
27690 auto val = vbound(value/10000,sscMIN+1,MAX_COUNTERS-1);
27691 size_t indx = ri->d[rINDEX]/10000;
27692 size_t sz = 0;
27693 byte ty = widg->getType();
27694 switch(ty)
27695 {
27696 case widgCOUNTER:
27697 sz = 3;
27698 break;
27699 case widgMISCGAUGE:
27700 sz = 1;
27701 break;
27702 default:
27703 sz = 0;
27704 bad_subwidg_type("Counter[]", false, ty);
27705 break;
27706 }
27707 if(!sz) break;
27708 if(indx >= sz)
27709 {
27710 Z_scripterrlog("Bad index '%d' to array "
27711 "'subscreenwidget->Counter[%d]'\n", indx, sz);
27712 break;
27713 }
27714 switch(ty)
27715 {
27716 case widgCOUNTER:
27717 ((SW_Counter*)widg)->ctrs[indx] = val;
27718 break;
27719 case widgMISCGAUGE:
27720 ((SW_MiscGaugePiece*)widg)->counter = val;
27721 break;
27722 }
27723 }
27724 break;
27725 }
27726 case SUBWIDGTY_MINDIG:
27727 {
27728 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "MinDigits"))
27729 {
27730 auto val = vbound(value/10000,0,5);
27731 auto ty = widg->getType();
27732 switch(ty)
27733 {
27734 case widgCOUNTER:
27735 ((SW_Counter*)widg)->mindigits = val;
27736 break;
27737 case widgBTNCOUNTER:
27738 ((SW_BtnCounter*)widg)->mindigits = val;
27739 break;
27740 case widgOLDCTR:
27741 ((SW_Counters*)widg)->digits = val;
27742 break;
27743 default:
27744 bad_subwidg_type("MinDigits", false, ty);
27745 break;
27746 }
27747 }
27748 break;
27749 }
27750 case SUBWIDGTY_MAXDIG:
27751 {
27752 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "MaxDigits"))
27753 {
27754 auto val = vbound(value/10000,0,5);
27755 auto ty = widg->getType();
27756 switch(ty)
27757 {
27758 case widgCOUNTER:
27759 ((SW_Counter*)widg)->maxdigits = val;
27760 break;
27761 case widgBTNCOUNTER:
27762 ((SW_BtnCounter*)widg)->maxdigits = val;
27763 break;
27764 default:
27765 bad_subwidg_type("MaxDigits", false, ty);
27766 break;
27767 }
27768 }
27769 break;
27770 }
27771 case SUBWIDGTY_INFITM:
27772 {
27773 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "InfiniteItem"))
27774 {
27775 auto val = vbound(value/10000,-1,MAXITEMS-1);
27776 auto ty = widg->getType();
27777 switch(ty)
27778 {
27779 case widgCOUNTER:
27780 ((SW_Counter*)widg)->infitm = val;
27781 break;
27782 case widgOLDCTR:
27783 ((SW_Counters*)widg)->infitm = val;
27784 break;
27785 case widgLGAUGE:
27786 case widgMGAUGE:
27787 case widgMISCGAUGE:
27788 ((SW_GaugePiece*)widg)->inf_item = val;
27789 break;
27790 default:
27791 bad_subwidg_type("InfiniteItem", false, ty);
27792 break;
27793 }
27794 }
27795 break;
27796 }
27797 case SUBWIDGTY_INFCHAR:
27798 {
27799 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "InfiniteChar"))
27800 {
27801 char val = vbound(value/10000,0,255);
27802 auto ty = widg->getType();
27803 switch(ty)
27804 {
27805 case widgCOUNTER:
27806 ((SW_Counter*)widg)->infchar = val;
27807 break;
27808 case widgBTNCOUNTER:
27809 ((SW_BtnCounter*)widg)->infchar = val;
27810 break;
27811 case widgOLDCTR:
27812 ((SW_Counters*)widg)->infchar = val;
27813 break;
27814 default:
27815 bad_subwidg_type("InfiniteChar", false, ty);
27816 break;
27817 }
27818 }
27819 break;
27820 }
27821 case SUBWIDGTY_COSTIND:
27822 {
27823 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "CostIndex"))
27824 {
27825 auto val = vbound(value/10000,0,1);
27826 auto ty = widg->getType();
27827 switch(ty)
27828 {
27829 case widgBTNCOUNTER:
27830 ((SW_BtnCounter*)widg)->costind = val;
27831 break;
27832 default:
27833 bad_subwidg_type("CostIndex", false, ty);
27834 break;
27835 }
27836 }
27837 break;
27838 }
27839 case SUBWIDGTY_COLOR_PLAYER:
27840 {
27841 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorPlayer"))
27842 {
27843 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27844 auto ty = widg->getType();
27845 switch(ty)
27846 {
27847 case widgMMAP:
27848 ((SW_MMap*)widg)->c_plr.set_int_color(val);
27849 break;
27850 case widgLMAP:
27851 ((SW_LMap*)widg)->c_plr.set_int_color(val);
27852 break;
27853 default:
27854 bad_subwidg_type("ColorPlayer", false, ty);
27855 break;
27856 }
27857 }
27858 break;
27859 }
27860 case SUBWIDGTY_COLOR_CMPBLNK:
27861 {
27862 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorCompassBlink"))
27863 {
27864 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27865 auto ty = widg->getType();
27866 switch(ty)
27867 {
27868 case widgMMAP:
27869 ((SW_MMap*)widg)->c_cmp_blink.set_int_color(val);
27870 break;
27871 default:
27872 bad_subwidg_type("ColorCompassBlink", false, ty);
27873 break;
27874 }
27875 }
27876 break;
27877 }
27878 case SUBWIDGTY_COLOR_CMPOFF:
27879 {
27880 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorCompassOff"))
27881 {
27882 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27883 auto ty = widg->getType();
27884 switch(ty)
27885 {
27886 case widgMMAP:
27887 ((SW_MMap*)widg)->c_cmp_off.set_int_color(val);
27888 break;
27889 default:
27890 bad_subwidg_type("ColorCompassOff", false, ty);
27891 break;
27892 }
27893 }
27894 break;
27895 }
27896 case SUBWIDGTY_COLOR_ROOM:
27897 {
27898 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorRoom"))
27899 {
27900 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27901 auto ty = widg->getType();
27902 switch(ty)
27903 {
27904 case widgLMAP:
27905 ((SW_LMap*)widg)->c_room.set_int_color(val);
27906 break;
27907 default:
27908 bad_subwidg_type("ColorRoom", false, ty);
27909 break;
27910 }
27911 }
27912 break;
27913 }
27914 case SUBWIDGTY_ITEMCLASS:
27915 {
27916 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ItemClass"))
27917 {
27918 auto val = vbound(value/10000,0,itype_maxusable-1);
27919 auto ty = widg->getType();
27920 switch(ty)
27921 {
27922 case widgITEMSLOT:
27923 ((SW_ItemSlot*)widg)->iclass = val;
27924 break;
27925 default:
27926 bad_subwidg_type("ItemClass", false, ty);
27927 break;
27928 }
27929 }
27930 break;
27931 }
27932 case SUBWIDGTY_ITEMID:
27933 {
27934 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ItemID"))
27935 {
27936 auto val = vbound(value/10000,-1,MAXITEMS-1);
27937 auto ty = widg->getType();
27938 switch(ty)
27939 {
27940 case widgITEMSLOT:
27941 ((SW_ItemSlot*)widg)->iid = val;
27942 break;
27943 default:
27944 bad_subwidg_type("ItemID", false, ty);
27945 break;
27946 }
27947 }
27948 break;
27949 }
27950 case SUBWIDGTY_FRAMETILE:
27951 {
27952 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "FrameTile"))
27953 {
27954 auto val = vbound(value/10000,0,NEWMAXTILES-1);
27955 auto ty = widg->getType();
27956 switch(ty)
27957 {
27958 case widgMCGUFF_FRAME:
27959 ((SW_TriFrame*)widg)->frame_tile = val;
27960 break;
27961 default:
27962 bad_subwidg_type("FrameTile", false, ty);
27963 break;
27964 }
27965 }
27966 break;
27967 }
27968 case SUBWIDGTY_FRAMECSET:
27969 {
27970 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "FrameCSet"))
27971 {
27972 auto val = vbound(value/10000,0,15);
27973 auto ty = widg->getType();
27974 switch(ty)
27975 {
27976 case widgMCGUFF_FRAME:
27977 ((SW_TriFrame*)widg)->frame_cset = val;
27978 break;
27979 default:
27980 bad_subwidg_type("FrameCSet", false, ty);
27981 break;
27982 }
27983 }
27984 break;
27985 }
27986 case SUBWIDGTY_PIECETILE:
27987 {
27988 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PieceTile"))
27989 {
27990 auto val = vbound(value/10000,0,NEWMAXTILES-1);
27991 auto ty = widg->getType();
27992 switch(ty)
27993 {
27994 case widgMCGUFF_FRAME:
27995 ((SW_TriFrame*)widg)->piece_tile = val;
27996 break;
27997 default:
27998 bad_subwidg_type("PieceTile", false, ty);
27999 break;
28000 }
28001 }
28002 break;
28003 }
28004 case SUBWIDGTY_PIECECSET:
28005 {
28006 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PieceCSet"))
28007 {
28008 auto val = vbound(value/10000,0,15);
28009 auto ty = widg->getType();
28010 switch(ty)
28011 {
28012 case widgMCGUFF_FRAME:
28013 ((SW_TriFrame*)widg)->piece_cset = val;
28014 break;
28015 default:
28016 bad_subwidg_type("PieceCSet", false, ty);
28017 break;
28018 }
28019 }
28020 break;
28021 }
28022 case SUBWIDGTY_FLIP:
28023 {
28024 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Flip"))
28025 {
28026 auto val = vbound(value/10000,0,15);
28027 auto ty = widg->getType();
28028 switch(ty)
28029 {
28030 case widgMCGUFF:
28031 ((SW_McGuffin*)widg)->flip = val;
28032 break;
28033 case widgTILEBLOCK:
28034 ((SW_TileBlock*)widg)->flip = val;
28035 break;
28036 case widgMINITILE:
28037 ((SW_MiniTile*)widg)->flip = val;
28038 break;
28039 default:
28040 bad_subwidg_type("Flip", false, ty);
28041 break;
28042 }
28043 }
28044 break;
28045 }
28046 case SUBWIDGTY_NUMBER:
28047 {
28048 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Number"))
28049 {
28050 auto val = vbound(value/10000,0,255);
28051 auto ty = widg->getType();
28052 switch(ty)
28053 {
28054 case widgMCGUFF:
28055 ((SW_McGuffin*)widg)->number = val;
28056 break;
28057 default:
28058 bad_subwidg_type("Number", false, ty);
28059 break;
28060 }
28061 }
28062 break;
28063 }
28064 case SUBWIDGTY_CORNER:
28065 {
28066 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Corner[]"))
28067 {
28068 auto val = vbound(value/10000,0,3);
28069 size_t indx = ri->d[rINDEX]/10000;
28070 size_t sz = 0;
28071 byte ty = widg->getType();
28072 switch(ty)
28073 {
28074 case widgMINITILE:
28075 sz = 1;
28076 break;
28077 case widgLGAUGE:
28078 case widgMGAUGE:
28079 case widgMISCGAUGE:
28080 sz = 4;
28081 break;
28082 default:
28083 sz = 0;
28084 bad_subwidg_type("Corner[]", false, ty);
28085 break;
28086 }
28087 if(!sz) break;
28088 if(indx >= sz)
28089 {
28090 Z_scripterrlog("Bad index '%d' to array "
28091 "'subscreenwidget->Corner[%d]'\n", indx, sz);
28092 break;
28093 }
28094 switch(ty)
28095 {
28096 case widgMINITILE:
28097 ((SW_MiniTile*)widg)->crn = val;
28098 break;
28099 case widgLGAUGE:
28100 case widgMGAUGE:
28101 case widgMISCGAUGE:
28102 ((SW_GaugePiece*)widg)->mts[indx].setCrn(val);
28103 break;
28104 }
28105 }
28106 break;
28107 }
28108 case SUBWIDGTY_FRAMES:
28109 {
28110 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Frames"))
28111 {
28112 auto val = vbound(value/10000,1,65535);
28113 auto ty = widg->getType();
28114 switch(ty)
28115 {
28116 case widgLGAUGE:
28117 case widgMGAUGE:
28118 case widgMISCGAUGE:
28119 ((SW_GaugePiece*)widg)->frames = val;
28120 break;
28121 default:
28122 bad_subwidg_type("Frames", false, ty);
28123 break;
28124 }
28125 }
28126 break;
28127 }
28128 case SUBWIDGTY_SPEED:
28129 {
28130 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Speed"))
28131 {
28132 auto val = vbound(value/10000,1,65535);
28133 auto ty = widg->getType();
28134 switch(ty)
28135 {
28136 case widgLGAUGE:
28137 case widgMGAUGE:
28138 case widgMISCGAUGE:
28139 ((SW_GaugePiece*)widg)->speed = val;
28140 break;
28141 default:
28142 bad_subwidg_type("Speed", false, ty);
28143 break;
28144 }
28145 }
28146 break;
28147 }
28148 case SUBWIDGTY_DELAY:
28149 {
28150 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Delay"))
28151 {
28152 auto val = vbound(value/10000,0,65535);
28153 auto ty = widg->getType();
28154 switch(ty)
28155 {
28156 case widgLGAUGE:
28157 case widgMGAUGE:
28158 case widgMISCGAUGE:
28159 ((SW_GaugePiece*)widg)->delay = val;
28160 break;
28161 default:
28162 bad_subwidg_type("Delay", false, ty);
28163 break;
28164 }
28165 }
28166 break;
28167 }
28168 case SUBWIDGTY_CONTAINER:
28169 {
28170 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Container"))
28171 {
28172 auto val = vbound(value/10000,0,65535);
28173 auto ty = widg->getType();
28174 switch(ty)
28175 {
28176 case widgLGAUGE:
28177 case widgMGAUGE:
28178 case widgMISCGAUGE:
28179 ((SW_GaugePiece*)widg)->container = val;
28180 break;
28181 default:
28182 bad_subwidg_type("Container", false, ty);
28183 break;
28184 }
28185 }
28186 break;
28187 }
28188 case SUBWIDGTY_GAUGE_WID:
28189 {
28190 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GaugeWid"))
28191 {
28192 auto val = vbound(value/10000,1,32)-1;
28193 auto ty = widg->getType();
28194 switch(ty)
28195 {
28196 case widgLGAUGE:
28197 case widgMGAUGE:
28198 case widgMISCGAUGE:
28199 ((SW_GaugePiece*)widg)->gauge_wid = val;
28200 break;
28201 default:
28202 bad_subwidg_type("GaugeWid", false, ty);
28203 break;
28204 }
28205 }
28206 break;
28207 }
28208 case SUBWIDGTY_GAUGE_HEI:
28209 {
28210 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GaugeHei"))
28211 {
28212 auto val = vbound(value/10000,1,32)-1;
28213 auto ty = widg->getType();
28214 switch(ty)
28215 {
28216 case widgLGAUGE:
28217 case widgMGAUGE:
28218 case widgMISCGAUGE:
28219 ((SW_GaugePiece*)widg)->gauge_hei = val;
28220 break;
28221 default:
28222 bad_subwidg_type("GaugeHei", false, ty);
28223 break;
28224 }
28225 }
28226 break;
28227 }
28228 case SUBWIDGTY_UNITS:
28229 {
28230 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Units"))
28231 {
28232 auto val = vbound(value/10000,1,256);
28233 auto ty = widg->getType();
28234 switch(ty)
28235 {
28236 case widgLGAUGE:
28237 case widgMGAUGE:
28238 case widgMISCGAUGE:
28239 ((SW_GaugePiece*)widg)->unit_per_frame = val-1;
28240 break;
28241 default:
28242 bad_subwidg_type("Units", false, ty);
28243 break;
28244 }
28245 }
28246 break;
28247 }
28248 case SUBWIDGTY_HSPACE:
28249 {
28250 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "HSpace"))
28251 {
28252 auto val = vbound(value/10000,-128,127);
28253 auto ty = widg->getType();
28254 switch(ty)
28255 {
28256 case widgLGAUGE:
28257 case widgMGAUGE:
28258 case widgMISCGAUGE:
28259 ((SW_GaugePiece*)widg)->hspace = val;
28260 break;
28261 default:
28262 bad_subwidg_type("HSpace", false, ty);
28263 break;
28264 }
28265 }
28266 break;
28267 }
28268 case SUBWIDGTY_VSPACE:
28269 {
28270 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "VSpace"))
28271 {
28272 auto val = vbound(value/10000,-128,127);
28273 auto ty = widg->getType();
28274 switch(ty)
28275 {
28276 case widgLGAUGE:
28277 case widgMGAUGE:
28278 case widgMISCGAUGE:
28279 ((SW_GaugePiece*)widg)->vspace = val;
28280 break;
28281 default:
28282 bad_subwidg_type("VSpace", false, ty);
28283 break;
28284 }
28285 }
28286 break;
28287 }
28288 case SUBWIDGTY_GRIDX:
28289 {
28290 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GridX"))
28291 {
28292 auto val = vbound(value/10000,-32768,32767);
28293 auto ty = widg->getType();
28294 switch(ty)
28295 {
28296 case widgLGAUGE:
28297 case widgMGAUGE:
28298 case widgMISCGAUGE:
28299 ((SW_GaugePiece*)widg)->grid_xoff = val;
28300 break;
28301 default:
28302 bad_subwidg_type("GridX", false, ty);
28303 break;
28304 }
28305 }
28306 break;
28307 }
28308 case SUBWIDGTY_GRIDY:
28309 {
28310 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GridY"))
28311 {
28312 auto val = vbound(value/10000,-32768,32767);
28313 auto ty = widg->getType();
28314 switch(ty)
28315 {
28316 case widgLGAUGE:
28317 case widgMGAUGE:
28318 case widgMISCGAUGE:
28319 ((SW_GaugePiece*)widg)->grid_yoff = val;
28320 break;
28321 default:
28322 bad_subwidg_type("GridY", false, ty);
28323 break;
28324 }
28325 }
28326 break;
28327 }
28328 case SUBWIDGTY_ANIMVAL:
28329 {
28330 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "AnimVal"))
28331 {
28332 auto val = vbound(value/10000,0,65535);
28333 auto ty = widg->getType();
28334 switch(ty)
28335 {
28336 case widgLGAUGE:
28337 case widgMGAUGE:
28338 case widgMISCGAUGE:
28339 ((SW_GaugePiece*)widg)->anim_val = val;
28340 break;
28341 default:
28342 bad_subwidg_type("AnimVal", false, ty);
28343 break;
28344 }
28345 }
28346 break;
28347 }
28348 case SUBWIDGTY_SHOWDRAIN:
28349 {
28350 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ShowDrain"))
28351 {
28352 auto val = vbound(value/10000,-1,32767);
28353 auto ty = widg->getType();
28354 switch(ty)
28355 {
28356 case widgMGAUGE:
28357 ((SW_MagicGaugePiece*)widg)->showdrain = val;
28358 break;
28359 default:
28360 bad_subwidg_type("ShowDrain", false, ty);
28361 break;
28362 }
28363 }
28364 break;
28365 }
28366 case SUBWIDGTY_PERCONTAINER:
28367 {
28368 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PerContainer"))
28369 {
28370 auto val = vbound(value/10000,1,65535);
28371 auto ty = widg->getType();
28372 switch(ty)
28373 {
28374 case widgMGAUGE:
28375 ((SW_MiscGaugePiece*)widg)->per_container = val;
28376 break;
28377 default:
28378 bad_subwidg_type("PerContainer", false, ty);
28379 break;
28380 }
28381 }
28382 break;
28383 }
28384 case SUBWIDGTY_TABSIZE:
28385 {
28386 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "TabSize"))
28387 {
28388 auto val = vbound(value/10000,0,255);
28389 auto ty = widg->getType();
28390 switch(ty)
28391 {
28392 case widgTEXTBOX:
28393 ((SW_TextBox*)widg)->tabsize = val;
28394 break;
28395 case widgSELECTEDTEXT:
28396 ((SW_SelectedText*)widg)->tabsize = val;
28397 break;
28398 default:
28399 bad_subwidg_type("TabSize", false, ty);
28400 break;
28401 }
28402 }
28403 break;
28404 }
28405 ///----------------------------------------------------------------------------------------------------//
28406
28407 default:
28408 {
28409
2/4
✓ Branch 0 taken 261531905 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 261531905 times.
261531905 if(arg >= D(0) && arg <= D(7)) ri->d[arg - D(0)] = value;
28410 else if(arg >= A(0) && arg <= A(1)) ri->a[arg - A(0)] = value;
28411 else if(arg >= GD(0) && arg <= GD(MAX_SCRIPT_REGISTERS)) game->global_d[arg-GD(0)] = value;
28412
28413 261531905 break;
28414 }
28415 }
28416 1399006287 } //end set_register
28417
28418 int32_t get_int_arr(const int32_t ptr, int32_t indx)
28419 {
28420 switch(ptr)
28421 {
28422 case INTARR_SCREEN_NPC:
28423 {
28424 if(BC::checkGuyIndex(indx, "Screen->NPCs[]") != SH::_NoError)
28425 return 0;
28426 return guys.spr(indx)->getUID();
28427 }
28428 case INTARR_SCREEN_ITEMSPR:
28429 {
28430 if(BC::checkItemIndex(indx, "Screen->Items[]") != SH::_NoError)
28431 return 0;
28432 return items.spr(indx)->getUID();
28433 }
28434 case INTARR_SCREEN_LWPN:
28435 {
28436 if(BC::checkLWeaponIndex(indx, "Screen->LWeapons[]") != SH::_NoError)
28437 return 0;
28438 return Lwpns.spr(indx)->getUID();
28439 }
28440 case INTARR_SCREEN_EWPN:
28441 {
28442 if(BC::checkEWeaponIndex(indx, "Screen->EWeapons[]") != SH::_NoError)
28443 return 0;
28444 return Ewpns.spr(indx)->getUID();
28445 }
28446 case INTARR_SCREEN_FFC:
28447 {
28448 if(BC::checkFFC(indx, "Screen->FFCs[]") != SH::_NoError)
28449 return 0;
28450 return indx*10000;
28451 }
28452 case INTARR_SCREEN_PORTALS:
28453 {
28454 if(BC::checkBoundsOneIndexed(indx, 0, portals.Count()-1, "Screen->Portals[]") != SH::_NoError)
28455 return 0;
28456 return portals.spr(indx)->getUID();
28457 }
28458 case INTARR_SAVPRTL:
28459 {
28460 if(BC::checkBoundsOneIndexed(indx, 0, game->user_portals.size()-1, "Game->SavedPortals[]") != SH::_NoError)
28461 return 0;
28462 return (indx+1)*10000;
28463 }
28464 default:
28465 {
28466 Z_scripterrlog("Unknown internal array '%d' read from!\n", ptr);
28467 return 0;
28468 }
28469 }
28470 }
28471 void set_int_arr(const int32_t ptr, int32_t indx, int32_t val)
28472 {
28473 switch(ptr)
28474 {
28475 case INTARR_SCREEN_NPC:
28476 Z_scripterrlog("Read-only array 'Screen->NPCs' cannot be written to!\n");
28477 return;
28478 case INTARR_SCREEN_ITEMSPR:
28479 Z_scripterrlog("Read-only array 'Screen->Items' cannot be written to!\n");
28480 return;
28481 case INTARR_SCREEN_LWPN:
28482 Z_scripterrlog("Read-only array 'Screen->LWeapons' cannot be written to!\n");
28483 return;
28484 case INTARR_SCREEN_EWPN:
28485 Z_scripterrlog("Read-only array 'Screen->EWeapons' cannot be written to!\n");
28486 return;
28487 case INTARR_SCREEN_FFC:
28488 Z_scripterrlog("Read-only array 'Screen->FFCs' cannot be written to!\n");
28489 return;
28490 case INTARR_SCREEN_PORTALS:
28491 Z_scripterrlog("Read-only array 'Screen->Portals' cannot be written to!\n");
28492 return;
28493 case INTARR_SAVPRTL:
28494 Z_scripterrlog("Read-only array 'Game->SavedPortals' cannot be written to!\n");
28495 return;
28496
28497 default:
28498 {
28499 Z_scripterrlog("Unknown internal array '%d' written to!\n", ptr);
28500 return;
28501 }
28502 }
28503 }
28504 int32_t sz_int_arr(const int32_t ptr)
28505 {
28506 switch(ptr)
28507 {
28508 case INTARR_SCREEN_NPC:
28509 {
28510 return guys.Count();
28511 }
28512 case INTARR_SCREEN_ITEMSPR:
28513 {
28514 return items.Count();
28515 }
28516 case INTARR_SCREEN_LWPN:
28517 {
28518 return Lwpns.Count();
28519 }
28520 case INTARR_SCREEN_EWPN:
28521 {
28522 return Ewpns.Count();
28523 }
28524 case INTARR_SCREEN_FFC:
28525 {
28526 return MAXFFCS;
28527 }
28528 case INTARR_SCREEN_PORTALS:
28529 {
28530 return portals.Count();
28531 }
28532 case INTARR_SAVPRTL:
28533 {
28534 return game->user_portals.size();
28535 }
28536 default:
28537 {
28538 Z_scripterrlog("Unknown internal array '%d' size read!\n", ptr);
28539 return -1;
28540 }
28541 }
28542 }
28543
28544 ///----------------------------------------------------------------------------------------------------//
28545 // ASM Functions //
28546 ///----------------------------------------------------------------------------------------------------//
28547
28548
28549 ///----------------------------------------------------------------------------------------------------//
28550 //Internal (to ZScript)
28551
28552 void do_set(const bool v, ScriptType whichType, const int32_t whichUID)
28553 {
28554 bool allowed = true;
28555 switch(whichType) //Check for objects attempting to change own script
28556 {
28557 //case ScriptType::Global:
28558
28559 case ScriptType::FFC:
28560 if(sarg1==FFSCRIPT && ri->ffcref==whichUID)
28561 allowed = false;
28562 break;
28563
28564 case ScriptType::Screen:
28565 if(sarg1==SCREENSCRIPT) //Only 1 screen script running at a time, no UID check needed
28566 allowed = false;
28567 break;
28568
28569 //case ScriptType::Player:
28570
28571 case ScriptType::Item:
28572 {
28573 bool collect = ( ( whichUID < 1 ) || (whichUID == COLLECT_SCRIPT_ITEM_ZERO) );
28574 int32_t new_UID = ( collect ) ? (( whichUID != COLLECT_SCRIPT_ITEM_ZERO ) ? (whichUID * -1) : 0) : whichUID;
28575
28576 if(collect)
28577 {
28578 if(sarg1==IDATAPSCRIPT && ri->idata==new_UID)
28579 allowed = false;
28580 }
28581 else if(sarg1==IDATASCRIPT && ri->idata==new_UID)
28582 allowed = false;
28583 break;
28584 }
28585
28586 case ScriptType::Lwpn:
28587 if(sarg1==LWPNSCRIPT && ri->lwpn==whichUID)
28588 allowed = false;
28589 break;
28590
28591 case ScriptType::NPC:
28592 if(sarg1==NPCSCRIPT && ri->guyref==whichUID)
28593 allowed = false;
28594 break;
28595
28596 case ScriptType::Ewpn:
28597 if(sarg1==EWPNSCRIPT && ri->ewpn==whichUID)
28598 allowed = false;
28599 break;
28600
28601 case ScriptType::DMap:
28602 if(sarg1==DMAPSCRIPT && ri->dmapsref==whichUID)
28603 allowed = false;
28604 break;
28605
28606 case ScriptType::ItemSprite:
28607 if(sarg1==ITEMSPRITESCRIPT && ri->itemref==whichUID)
28608 allowed = false;
28609 break;
28610 }
28611 if(!allowed)
28612 {
28613 Z_scripterrlog("Script attempted to change own object's script! This has been ignored.\n");
28614 return;
28615 }
28616 int32_t temp = SH::get_arg(sarg2, v);
28617 set_register(sarg1, temp);
28618 }
28619
28620 void do_push(const bool v)
28621 {
28622 const int32_t value = SH::get_arg(sarg1, v);
28623 --ri->sp;
28624 ri->sp &= MASK_SP;
28625 SH::write_stack(ri->sp, value);
28626 }
28627 59806 void do_push_varg(const bool v)
28628 {
28629 59806 const int32_t value = SH::get_arg(sarg1, v);
28630 59806 zs_vargs.push_back(value);
28631 59806 }
28632
28633 void do_pop()
28634 {
28635 const int32_t value = SH::read_stack(ri->sp);
28636 ++ri->sp;
28637 ri->sp &= MASK_SP;
28638 set_register(sarg1, value);
28639 }
28640
28641 72811 void do_peek()
28642 {
28643 72811 set_register(sarg1, SH::read_stack(ri->sp));
28644 72811 }
28645
28646 void do_peekat(const bool v)
28647 {
28648 auto offs = SH::get_arg(sarg2,v);
28649 set_register(sarg1, SH::read_stack(ri->sp+offs));
28650 }
28651
28652 void do_pops() // Pop past a bunch of stuff at once. Useful for clearing the stack.
28653 {
28654 int32_t num = sarg2;
28655 ri->sp += num;
28656 ri->sp &= MASK_SP;
28657 word read = (ri->sp-1) & MASK_SP;
28658 int32_t value = SH::read_stack(read);
28659 set_register(sarg1, value);
28660 }
28661
28662 void do_loadi()
28663 {
28664 const int32_t stackoffset = get_register(sarg2) / 10000;
28665 const int32_t value = SH::read_stack(stackoffset);
28666 set_register(sarg1, value);
28667 }
28668
28669 void do_storei()
28670 {
28671 const int32_t stackoffset = get_register(sarg2) / 10000;
28672 const int32_t value = get_register(sarg1);
28673 SH::write_stack(stackoffset, value);
28674 }
28675
28676 void do_loadd()
28677 {
28678 const int32_t stackoffset = (sarg2+ri->d[rSFRAME]) / 10000;
28679 const int32_t value = SH::read_stack(stackoffset);
28680 set_register(sarg1, value);
28681 }
28682
28683 void do_stored()
28684 {
28685 const int32_t stackoffset = (sarg2+ri->d[rSFRAME]) / 10000;
28686 const int32_t value = get_register(sarg1);
28687 SH::write_stack(stackoffset, value);
28688 }
28689
28690 void do_enqueue(const bool)
28691 {
28692 }
28693 void do_dequeue(const bool)
28694 {
28695 }
28696
28697 void do_comp(bool v, const bool inv = false)
28698 {
28699 bool v2 = false;
28700 if(inv) zc_swap(v,v2);
28701 int32_t temp = SH::get_arg(sarg2, v);
28702 int32_t temp2 = SH::get_arg(sarg1, v2);
28703
28704 if(temp2 >= temp) ri->scriptflag |= MOREFLAG;
28705 else ri->scriptflag &= ~MOREFLAG;
28706
28707 if(temp2 == temp) ri->scriptflag |= TRUEFLAG;
28708 else ri->scriptflag &= ~TRUEFLAG;
28709 }
28710
28711 void do_internal_strcmp()
28712 {
28713 int32_t arrayptr_a = get_register(sarg1)/10000;
28714 int32_t arrayptr_b = get_register(sarg2)/10000;
28715 string strA;
28716 string strB;
28717 ArrayH::getString(arrayptr_a, strA);
28718 ArrayH::getString(arrayptr_b, strB);
28719 int32_t temp = strcmp(strA.c_str(), strB.c_str());
28720
28721 if(temp >= 0) ri->scriptflag |= MOREFLAG;
28722 else ri->scriptflag &= ~MOREFLAG;
28723
28724 if(temp == 0) ri->scriptflag |= TRUEFLAG;
28725 else ri->scriptflag &= ~TRUEFLAG;
28726 }
28727
28728 void do_internal_stricmp()
28729 {
28730 int32_t arrayptr_a = get_register(sarg1)/10000;
28731 int32_t arrayptr_b = get_register(sarg2)/10000;
28732 string strA;
28733 string strB;
28734 ArrayH::getString(arrayptr_a, strA);
28735 ArrayH::getString(arrayptr_b, strB);
28736 int32_t temp = stricmp(strA.c_str(), strB.c_str());
28737
28738 if(temp >= 0) ri->scriptflag |= MOREFLAG;
28739 else ri->scriptflag &= ~MOREFLAG;
28740
28741 if(temp == 0) ri->scriptflag |= TRUEFLAG;
28742 else ri->scriptflag &= ~TRUEFLAG;
28743 }
28744
28745 void do_resize_array()
28746 {
28747 int32_t size = vbound(get_register(sarg2) / 10000, 0, 214748);
28748 dword ptrval = get_register(sarg1) / 10000;
28749 ArrayManager am(ptrval);
28750 am.resize(size);
28751 }
28752
28753 void do_own_array(dword arrindx, ScriptType scriptType, const int32_t UID)
28754 {
28755 ArrayManager am(arrindx);
28756
28757 if(am.internal())
28758 {
28759 Z_scripterrlog("Cannot 'OwnArray()' an internal array '%d'\n", arrindx);
28760 return;
28761 }
28762 if(arrindx >= NUM_ZSCRIPT_ARRAYS && arrindx < NUM_ZSCRIPT_ARRAYS*2)
28763 {
28764 //ignore global arrays
28765 }
28766 else if(!am.invalid())
28767 {
28768 if(arrindx > 0 && arrindx < NUM_ZSCRIPT_ARRAYS)
28769 {
28770 arrayOwner[arrindx].reown(scriptType, UID);
28771 }
28772 else if(arrindx < 0) //object array
28773 Z_scripterrlog("Cannot 'OwnArray()' an object-based array '%d'\n", arrindx);
28774 }
28775 else Z_scripterrlog("Tried to 'OwnArray()' an invalid array '%d'\n", arrindx);
28776 }
28777 void do_destroy_array()
28778 {
28779 dword arrindx = get_register(sarg1) / 10000;
28780
28781 ArrayManager am(arrindx);
28782
28783 if(am.internal())
28784 {
28785 Z_scripterrlog("Cannot 'DestroyArray()' an internal array '%d'\n", arrindx);
28786 return;
28787 }
28788
28789 if(arrindx >= NUM_ZSCRIPT_ARRAYS && arrindx < NUM_ZSCRIPT_ARRAYS*2)
28790 {
28791 //ignore global arrays
28792 }
28793 else if(!am.invalid())
28794 {
28795 if(arrindx > 0 && arrindx < NUM_ZSCRIPT_ARRAYS)
28796 {
28797 arrayOwner[arrindx].clear();
28798
28799 if(localRAM[arrindx].Valid())
28800 localRAM[arrindx].Clear();
28801
28802 arrayOwner[arrindx].specCleared = true;
28803 }
28804 else if(arrindx < 0) //object array
28805 Z_scripterrlog("Cannot 'DestroyArray()' an object-based array '%d'\n", arrindx);
28806 }
28807 else Z_scripterrlog("Tried to 'DestroyArray()' an invalid array '%d'\n", arrindx);
28808 }
28809 7008514 void do_allocatemem(const bool v, const bool local, ScriptType type, const uint32_t UID)
28810 {
28811 7008514 const int32_t size = SH::get_arg(sarg2, v) / 10000;
28812 dword ptrval;
28813
28814
1/2
✓ Branch 0 taken 7008514 times.
✗ Branch 1 not taken.
7008514 if(size < 0)
28815 {
28816 Z_scripterrlog("Array initialized to invalid size of %d\n", size);
28817 set_register(sarg1, 0); //Pass back NULL
28818 return;
28819 }
28820
28821
2/2
✓ Branch 0 taken 7008212 times.
✓ Branch 1 taken 302 times.
7008514 if(local)
28822 {
28823 //localRAM[0] is used as an invalid container, so 0 can be the NULL pointer in ZScript
28824
2/2
✓ Branch 0 taken 383449995 times.
✓ Branch 1 taken 7008212 times.
390458207 for(ptrval = 1; localRAM[ptrval].Valid(); ptrval++) ;
28825
28826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7008212 times.
7008212 if(ptrval >= NUM_ZSCRIPT_ARRAYS)
28827 {
28828 Z_scripterrlog("%d local arrays already in use, no more can be allocated\n", NUM_ZSCRIPT_ARRAYS-1);
28829 ptrval = 0;
28830 }
28831 else
28832 {
28833 7008212 ZScriptArray &a = localRAM[ptrval]; //marginally faster for large arrays if we use a reference
28834
28835 7008212 a.Resize(size);
28836 7008212 a.setValid(true);
28837
28838
2/2
✓ Branch 0 taken 106921697 times.
✓ Branch 1 taken 7008212 times.
113929909 for(dword j = 0; j < (dword)size; j++)
28839 106921697 a[j] = 0; //initialize array
28840
28841 // Keep track of which object created the array so we know which to deallocate
28842 //Z_eventlog("Allocating array %d to script %s, %d\n", ptrval, script_types[type], UID);
28843 7008212 arrayOwner[ptrval].reown(type, UID);
28844 }
28845 7008212 }
28846 else
28847 {
28848 //Globals are only allocated here at first play, otherwise in init_game
28849
2/2
✓ Branch 0 taken 5347 times.
✓ Branch 1 taken 302 times.
5649 for(ptrval = 0; game->globalRAM[ptrval].Valid(); ptrval++) ;
28850
28851
1/2
✓ Branch 0 taken 302 times.
✗ Branch 1 not taken.
302 if(ptrval >= game->globalRAM.size())
28852 {
28853 al_trace("Invalid pointer value of %u passed to global allocate\n", ptrval);
28854 //this shouldn't happen, unless people are putting ALLOCATEGMEM in their ZASM scripts where they shouldn't be
28855 }
28856
28857 302 ZScriptArray &a = game->globalRAM[ptrval];
28858
28859 302 a.Resize(size);
28860 302 a.setValid(true);
28861
28862
2/2
✓ Branch 0 taken 455421 times.
✓ Branch 1 taken 302 times.
455723 for(dword j = 0; j < (dword)size; j++)
28863 455421 a[j] = 0;
28864
28865 302 ptrval += NUM_ZSCRIPT_ARRAYS; //so each pointer has a unique value
28866 }
28867
28868
28869 7008514 set_register(sarg1, ptrval * 10000);
28870
28871 // If this happens once per frame, it can drown out every other message. -L
28872 /*Z_eventlog("Allocated %s array of size %d, pointer address %ld\n",
28873 local ? "local": "global", size, ptrval);*/
28874 7008514 }
28875
28876 6983690 void do_deallocatemem()
28877 {
28878 6983690 const int32_t ptrval = get_register(sarg1) / 10000;
28879
28880 6983690 FFScript::deallocateZScriptArray(ptrval);
28881 6983690 }
28882
28883 void do_loada(const byte a)
28884 {
28885 if(ri->a[a] == 0)
28886 {
28887 Z_eventlog("Global scripts currently have no A registers\n");
28888 return;
28889 }
28890
28891 int32_t ffcref = (ri->a[a] / 10000) - 1; //FFC 2
28892
28893 if(BC::checkFFC(ffcref, "LOAD%i") != SH::_NoError)
28894 return;
28895
28896 int32_t reg = get_register(sarg2); //Register in FFC 2
28897
28898 if(reg >= D(0) && reg <= D(7))
28899 set_register(sarg1, FFCore.ref(ScriptType::FFC, ffcref).d[reg - D(0)]); //get back the info into *sarg1
28900 else if(reg == A(0) || reg == A(1))
28901 set_register(sarg1, FFCore.ref(ScriptType::FFC, ffcref).a[reg - A(0)]);
28902 else if(reg == SP)
28903 set_register(sarg1, FFCore.ref(ScriptType::FFC, ffcref).sp * 10000);
28904
28905 //Can get everything else using REFFFC
28906 }
28907
28908 void do_seta(const byte a)
28909 {
28910 if(ri->a[a] == 0)
28911 {
28912 Z_eventlog("Global scripts currently have no A registers\n");
28913 return;
28914 }
28915
28916 int32_t ffcref = (ri->a[a] / 10000) - 1; //FFC 2
28917
28918 if(BC::checkFFC(ffcref, "SETA%i") != SH::_NoError)
28919 return;
28920
28921 int32_t reg = get_register(sarg2); //Register in FFC 2
28922
28923 if(reg >= D(0) && reg <= D(7))
28924 FFCore.ref(ScriptType::FFC, ffcref).d[reg - D(0)] = get_register(sarg1); //Set it to *sarg1
28925 else if(reg == A(0) || reg == A(1))
28926 FFCore.ref(ScriptType::FFC, ffcref).a[reg - A(0)] = get_register(sarg1);
28927 else if(reg == SP)
28928 FFCore.ref(ScriptType::FFC, ffcref).sp = get_register(sarg1) / 10000;
28929 }
28930
28931 ///----------------------------------------------------------------------------------------------------//
28932 //Mathematical
28933
28934 void do_add(const bool v)
28935 {
28936 int32_t temp = SH::get_arg(sarg2, v);
28937 int32_t temp2 = get_register(sarg1);
28938
28939 set_register(sarg1, temp2 + temp);
28940 }
28941
28942 void do_sub(bool v, const bool inv = false)
28943 {
28944 bool v2 = false;
28945 if(inv) zc_swap(v,v2);
28946 auto destreg = (inv ? sarg2 : sarg1);
28947 int32_t temp = SH::get_arg(sarg2, v);
28948 int32_t temp2 = SH::get_arg(sarg1, v2);
28949 //zprint2("Subtraction found: '%d - %d' where '%s - %s'\n", temp2, temp, v2 ? "const" : "reg", v ? "const" : "reg");
28950 set_register(destreg, temp2 - temp);
28951 }
28952
28953 void do_mult(const bool v)
28954 {
28955 int64_t temp = SH::get_arg(sarg2, v);
28956 int32_t temp2 = get_register(sarg1);
28957
28958 set_register(sarg1, int32_t((temp * temp2) / 10000));
28959 }
28960
28961 708 void do_div(bool v, const bool inv = false)
28962 {
28963 708 bool v2 = false;
28964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708 times.
708 if(inv) zc_swap(v,v2);
28965
1/2
✓ Branch 0 taken 708 times.
✗ Branch 1 not taken.
708 auto destreg = (inv ? sarg2 : sarg1);
28966 708 int64_t temp = SH::get_arg(sarg2, v);
28967 708 int64_t temp2 = SH::get_arg(sarg1, v2);
28968
28969
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 696 times.
708 if(temp == 0)
28970 {
28971 12 Z_scripterrlog("Script attempted to divide %ld by zero!\n", temp2);
28972 12 set_register(destreg, int32_t(sign(temp2) * MAX_SIGNED_32));
28973 12 }
28974 else
28975 {
28976 696 set_register(destreg, int32_t((temp2 * 10000) / temp));
28977 }
28978 708 }
28979
28980 252 void do_mod(bool v, const bool inv = false)
28981 {
28982 252 bool v2 = false;
28983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(inv) zc_swap(v,v2);
28984
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 auto destreg = (inv ? sarg2 : sarg1);
28985 252 int32_t temp = SH::get_arg(sarg2, v);
28986 252 int32_t temp2 = SH::get_arg(sarg1, v2);
28987
28988
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 240 times.
252 if(temp == 0)
28989 {
28990 12 Z_scripterrlog("Script attempted to modulo %ld by zero!\n",temp2);
28991 12 temp = 1;
28992 12 }
28993
28994 252 set_register(destreg, temp2 % temp);
28995 252 }
28996
28997 9370865 void do_trig(const bool v, const byte type)
28998 {
28999 9370865 double rangle = (SH::get_arg(sarg2, v) / 10000.0) * PI / 180.0;
29000
29001
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6164970 times.
✓ Branch 2 taken 3205819 times.
✓ Branch 3 taken 76 times.
9370865 switch(type)
29002 {
29003 case 0:
29004 6164970 set_register(sarg1, int32_t(zc::math::Sin(rangle) * 10000.0));
29005 6164970 break;
29006
29007 case 1:
29008 3205819 set_register(sarg1, int32_t(zc::math::Cos(rangle) * 10000.0));
29009 3205819 break;
29010
29011 case 2:
29012 76 set_register(sarg1, int32_t(zc::math::Tan(rangle) * 10000.0));
29013 76 break;
29014 }
29015 9370865 }
29016
29017 1263 void do_degtorad()
29018 {
29019 1263 double rangle = (SH::get_arg(sarg2, false) / 10000.0) * (PI / 180.0);
29020 1263 rangle += rangle < 0?-0.00005:0.00005;
29021
29022 1263 set_register(sarg1, int32_t(rangle * 10000.0));
29023 1263 }
29024
29025 60936 void do_radtodeg()
29026 {
29027 60936 double rangle = (SH::get_arg(sarg2, false) / 10000.0) * (180.0 / PI);
29028
29029 60936 set_register(sarg1, int32_t(rangle * 10000.0));
29030 60936 }
29031
29032 14918 void do_asin(const bool v)
29033 {
29034 14918 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
29035
29036
2/4
✓ Branch 0 taken 14918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14918 times.
✗ Branch 3 not taken.
14918 if(temp >= -1 && temp <= 1)
29037 14918 set_register(sarg1, int32_t(asin(temp) * 10000.0));
29038 else
29039 {
29040 Z_scripterrlog("Script attempted to pass %ld into ArcSin!\n",temp);
29041 set_register(sarg1, -10000);
29042 }
29043 14918 }
29044
29045 void do_acos(const bool v)
29046 {
29047 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
29048
29049 if(temp >= -1 && temp <= 1)
29050 set_register(sarg1, int32_t(acos(temp) * 10000.0));
29051 else
29052 {
29053 Z_scripterrlog("Script attempted to pass %ld into ArcCos!\n",temp);
29054 set_register(sarg1, -10000);
29055 }
29056 }
29057
29058 864999 void do_arctan()
29059 {
29060 864999 double xpos = ri->d[rINDEX] / 10000.0;
29061 864999 double ypos = ri->d[rINDEX2] / 10000.0;
29062
29063 864999 set_register(sarg1, int32_t(atan2(ypos, xpos) * 10000.0));
29064 864999 }
29065
29066 void do_abs(const bool v)
29067 {
29068 int32_t temp = SH::get_arg(sarg1, v);
29069 set_register(sarg1, abs(temp));
29070 }
29071
29072 27 void do_log10(const bool v)
29073 {
29074 27 double temp = double(SH::get_arg(sarg1, v)) / 10000.0;
29075
29076
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(temp > 0)
29077 27 set_register(sarg1, int32_t(log10(temp) * 10000.0));
29078 else
29079 {
29080 Z_eventlog("Script tried to calculate log of %f\n", temp / 10000.0);
29081 set_register(sarg1, 0);
29082 }
29083 27 }
29084
29085 20 void do_naturallog(const bool v)
29086 {
29087 20 double temp = double(SH::get_arg(sarg1, v)) / 10000.0;
29088
29089
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(temp > 0)
29090 20 set_register(sarg1, int32_t(log(temp) * 10000.0));
29091 // else if(temp == 0)
29092 // {
29093 // Z_eventlog("Script tried to calculate ln of 0\n");
29094 // set_register(sarg1, MIN_SIGNED_32);
29095 // }
29096 else
29097 {
29098 Z_eventlog("Script tried to calculate ln of %f\n", temp / 10000.0);
29099 set_register(sarg1, 0);
29100 }
29101 20 }
29102
29103 void do_min(const bool v)
29104 {
29105 int32_t temp = SH::get_arg(sarg2, v);
29106 int32_t temp2 = get_register(sarg1);
29107 set_register(sarg1, zc_min(temp2, temp));
29108 }
29109
29110 void do_max(const bool v)
29111 {
29112 int32_t temp = SH::get_arg(sarg2, v);
29113 int32_t temp2 = get_register(sarg1);
29114
29115 set_register(sarg1, zc_max(temp2, temp));
29116 }
29117
29118
29119 2703958 void do_rnd(const bool v)
29120 {
29121 2703958 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29122
29123
2/2
✓ Branch 0 taken 2703775 times.
✓ Branch 1 taken 183 times.
2703958 if(temp > 0)
29124 2703775 set_register(sarg1, (zc_oldrand() % temp) * 10000);
29125
1/2
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
183 else if(temp < 0)
29126 183 set_register(sarg1, (zc_oldrand() % (-temp)) * -10000);
29127 else
29128 set_register(sarg1, 0); // Just return 0. (Do not log an error)
29129 2703958 }
29130
29131 void do_srnd(const bool v)
29132 {
29133 uint32_t seed = SH::get_arg(sarg1, v); //Do not `/10000`- allow the decimal portion to be used! -V
29134 zc_game_srand(seed);
29135 }
29136
29137 void do_srndrnd()
29138 {
29139 //Randomize the seed to the current system time, + or - the product of 2 random numbers.
29140 int32_t seed = time(0) + ((zc_rand() * int64_t(zc_rand())) * (zc_rand(1) ? 1 : -1));
29141 set_register(sarg1, seed);
29142 zc_game_srand(seed);
29143 }
29144
29145 //Returns the system Real-Time-Clock value for a specific type.
29146 void FFScript::getRTC(const bool v)
29147 {
29148 //int32_t type = get_register(sarg1) / 10000;
29149 //zprint("FFCore.getRTC() type == %d\n",type);
29150 //int32_t time = getTime(type);
29151 //zprint("FFCore.getRTC() time == %d\n",time);
29152 //zprint("FFCore.getRTC() time * 10000 == %d\n",time);
29153 //set_register(sarg1, getTime((byte)(SH::get_arg(sarg2, v) / 10000)) * 10000);
29154 set_register(sarg1, getTime((get_register(sarg1) / 10000)) * 10000);
29155 }
29156
29157
29158 void do_factorial(const bool v)
29159 {
29160 int32_t temp;
29161
29162 if(v)
29163 return; //must factorial a register, not a value (why is this exactly? ~Joe123)
29164 else
29165 {
29166 temp = get_register(sarg1) / 10000;
29167
29168 if(temp < 2)
29169 {
29170 set_register(sarg1, temp >= 0 ? 10000 : 00000);
29171 return;
29172 }
29173 }
29174
29175 int32_t temp2 = 1;
29176
29177 for(int32_t temp3 = temp; temp > 1; temp--)
29178 temp2 *= temp3;
29179
29180 set_register(sarg1, temp2 * 10000);
29181 }
29182
29183 77 void do_power(bool v, const bool inv = false)
29184 {
29185 77 bool v2 = false;
29186
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(inv) zc_swap(v,v2);
29187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 auto destreg = (inv ? sarg2 : sarg1);
29188 77 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
29189 77 double temp2 = double(SH::get_arg(sarg1, v2)) / 10000.0;
29190
29191
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
77 if(temp == 0 && temp2 == 0)
29192 {
29193 set_register(destreg, 10000);
29194 return;
29195 }
29196
29197 77 set_register(destreg, int32_t(pow(temp2, temp) * 10000.0));
29198 77 }
29199
29200 void do_lpower(bool v, const bool inv = false)
29201 {
29202 bool v2 = false;
29203 if(inv) zc_swap(v,v2);
29204 auto destreg = (inv ? sarg2 : sarg1);
29205 int32_t temp = SH::get_arg(sarg2, v);
29206 int32_t temp2 = SH::get_arg(sarg1, v2);
29207
29208 if(temp == 0 && temp2 == 0)
29209 {
29210 set_register(destreg, 1);
29211 return;
29212 }
29213
29214 set_register(destreg, int32_t(pow(temp2, temp)));
29215 }
29216
29217 //could use recursion or something to avoid truncation.
29218 void do_ipower(const bool v)
29219 {
29220 double sarg2val = double(SH::get_arg(sarg2, v));
29221 if ( sarg2val == 0 )
29222 {
29223 Z_scripterrlog("Division by 0 Err: InvPower() exponent divisor cannot be 0!!\n");
29224 set_register(sarg1, 1);
29225 return;
29226 }
29227 double temp = 10000.0 / sarg2val;
29228 double temp2 = double(get_register(sarg1)) / 10000.0;
29229
29230 if(temp == 0 && temp2 == 0)
29231 {
29232 Z_scripterrlog("Script attempted to calculate 0 to the power 0!\n");
29233 set_register(sarg1, 1);
29234 return;
29235 }
29236
29237 set_register(sarg1, int32_t(pow(temp2, temp) * 10000.0));
29238 }
29239
29240 2539388 void do_sqroot(const bool v)
29241 {
29242 2539388 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
29243
29244
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 2538966 times.
2539388 if(temp < 0)
29245 {
29246 422 Z_scripterrlog("Script attempted to calculate square root of %ld!\n", temp);
29247 422 set_register(sarg1, -10000);
29248 422 return;
29249 }
29250
29251 2538966 set_register(sarg1, int32_t(sqrt(temp) * 10000.0));
29252 2539388 }
29253
29254 ///----------------------------------------------------------------------------------------------------//
29255 //Bitwise
29256
29257 void do_and(const bool v)
29258 {
29259 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29260 int32_t temp2 = get_register(sarg1) / 10000;
29261 set_register(sarg1, (temp2 & temp) * 10000);
29262 }
29263
29264 34306 void do_and32(const bool v)
29265 {
29266 34306 int32_t temp = SH::get_arg(sarg2, v);
29267 34306 int32_t temp2 = get_register(sarg1);
29268 34306 set_register(sarg1, (temp2 & temp));
29269 34306 }
29270
29271 5736110 void do_or(const bool v)
29272 {
29273 5736110 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29274 5736110 int32_t temp2 = get_register(sarg1) / 10000;
29275 5736110 set_register(sarg1, (temp2 | temp) * 10000);
29276 5736110 }
29277
29278 17 void do_or32(const bool v)
29279 {
29280 17 int32_t temp = SH::get_arg(sarg2, v);
29281 17 int32_t temp2 = get_register(sarg1);
29282 17 set_register(sarg1, (temp2 | temp));
29283 17 }
29284
29285 191297 void do_xor(const bool v)
29286 {
29287 191297 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29288 191297 int32_t temp2 = get_register(sarg1) / 10000;
29289 191297 set_register(sarg1, (temp2 ^ temp) * 10000);
29290 191297 }
29291
29292 void do_xor32(const bool v)
29293 {
29294 int32_t temp = SH::get_arg(sarg2, v);
29295 int32_t temp2 = get_register(sarg1);
29296 set_register(sarg1, (temp2 ^ temp));
29297 }
29298
29299 void do_nand(const bool v)
29300 {
29301 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29302 int32_t temp2 = get_register(sarg1) / 10000;
29303 set_register(sarg1, (~(temp2 & temp)) * 10000);
29304 }
29305
29306 void do_nor(const bool v)
29307 {
29308 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29309 int32_t temp2 = get_register(sarg1) / 10000;
29310 set_register(sarg1, (~(temp2 | temp)) * 10000);
29311 }
29312
29313 void do_xnor(const bool v)
29314 {
29315 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29316 int32_t temp2 = get_register(sarg1) / 10000;
29317 set_register(sarg1, (~(temp2 ^ temp)) * 10000);
29318 }
29319
29320 void do_not(const bool v)
29321 {
29322 int32_t temp = SH::get_arg(sarg2, v);
29323 set_register(sarg1, !temp);
29324 }
29325
29326 1427960 void do_bitwisenot(const bool v)
29327 {
29328 1427960 int32_t temp = SH::get_arg(sarg1, v) / 10000;
29329 1427960 set_register(sarg1, (~temp) * 10000);
29330 1427960 }
29331
29332 void do_bitwisenot32(const bool v)
29333 {
29334 int32_t temp = SH::get_arg(sarg1, v);
29335 set_register(sarg1, (~temp));
29336 }
29337
29338 62748017 void do_lshift(const bool v)
29339 {
29340 62748017 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29341 62748017 int32_t temp2 = get_register(sarg1) / 10000;
29342 62748017 set_register(sarg1, (temp2 << temp) * 10000);
29343 62748017 }
29344
29345 22 void do_lshift32(const bool v)
29346 {
29347 22 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29348 22 int32_t temp2 = get_register(sarg1);
29349 22 set_register(sarg1, (temp2 << temp));
29350 22 }
29351
29352 20519695 void do_rshift(const bool v)
29353 {
29354 20519695 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29355 20519695 int32_t temp2 = get_register(sarg1) / 10000;
29356 20519695 set_register(sarg1, (temp2 >> temp) * 10000);
29357 20519695 }
29358
29359 34296 void do_rshift32(const bool v)
29360 {
29361 34296 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29362 34296 int32_t temp2 = get_register(sarg1);
29363 34296 set_register(sarg1, (temp2 >> temp));
29364 34296 }
29365
29366 ///----------------------------------------------------------------------------------------------------//
29367 //Casting
29368
29369 void do_boolcast(const bool isFloat)
29370 {
29371 set_register(sarg1, (get_register(sarg1) ? (isFloat ? 1 : 10000) : 0));
29372 }
29373
29374 ///----------------------------------------------------------------------------------------------------//
29375 //Text ptr functions
29376 void do_fontheight()
29377 {
29378 int32_t font = get_register(sarg1)/10000;
29379 ri->d[rEXP1] = text_height(get_zc_font(font))*10000;
29380 }
29381
29382 13724 void do_strwidth()
29383 {
29384 13724 int32_t strptr = get_register(sarg1)/10000;
29385 13724 int32_t font = get_register(sarg2)/10000;
29386 13724 string the_string;
29387
1/2
✓ Branch 0 taken 13724 times.
✗ Branch 1 not taken.
13724 ArrayH::getString(strptr, the_string, 512);
29388
2/4
✓ Branch 0 taken 13724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13724 times.
✗ Branch 3 not taken.
13724 ri->d[rEXP1] = text_length(get_zc_font(font), the_string.c_str())*10000;
29389 13724 }
29390
29391 15144 void do_charwidth()
29392 {
29393 15144 char chr = get_register(sarg1)/10000;
29394 15144 int32_t font = get_register(sarg2)/10000;
29395 15144 char *cstr = new char[2];
29396 15144 cstr[0] = chr;
29397 15144 cstr[1] = '\0';
29398 15144 ri->d[rEXP1] = text_length(get_zc_font(font), cstr)*10000;
29399
1/2
✓ Branch 0 taken 15144 times.
✗ Branch 1 not taken.
15144 delete[] cstr;
29400 15144 }
29401
29402 int32_t do_msgwidth(int32_t msg, char const* str)
29403 {
29404 if(BC::checkMessage(msg, str) != SH::_NoError)
29405 {
29406 return -1;
29407 }
29408
29409 int32_t v = text_length(get_zc_font(MsgStrings[msg].font),
29410 MsgStrings[msg].s.substr(0,MsgStrings[msg].s.find_last_not_of(' ')+1).c_str());
29411 return v;
29412 }
29413
29414 int32_t do_msgheight(int32_t msg, char const* str)
29415 {
29416 if(BC::checkMessage(msg, str) != SH::_NoError)
29417 {
29418 return -1;
29419 }
29420 return text_height(get_zc_font(MsgStrings[msg].font));
29421 }
29422
29423 ///----------------------------------------------------------------------------------------------------//
29424 //Gameplay functions
29425
29426 79 void do_warp(bool v)
29427 {
29428 79 int32_t dmapid = SH::get_arg(sarg1, v) / 10000;
29429 79 int32_t screenid = SH::get_arg(sarg2, v) / 10000;
29430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ( ((unsigned)dmapid) >= MAXDMAPS )
29431 {
29432 Z_scripterrlog("Invalid DMap ID (%d) passed to Warp(). Aborting.\n", dmapid);
29433 return;
29434 }
29435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ( ((unsigned)screenid) >= MAPSCRS )
29436 {
29437 Z_scripterrlog("Invalid Screen ID (%d) passed to Warp(). Aborting.\n", screenid);
29438 return;
29439 }
29440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ( DMaps[dmapid].map*MAPSCRS+DMaps[dmapid].xoff+screenid >= (int32_t)TheMaps.size() )
29441 {
29442 Z_scripterrlog("Invalid destination passed to Warp(). Aborting.\n");
29443 return;
29444 }
29445 79 tmpscr->sidewarpdmap[0] = dmapid;
29446 79 tmpscr->sidewarpscr[0] = screenid;
29447 79 tmpscr->sidewarptype[0] = wtIWARP;
29448 79 Hero.ffwarp = true;
29449 79 }
29450
29451 126 void do_pitwarp(bool v)
29452 {
29453 126 int32_t dmapid = SH::get_arg(sarg1, v) / 10000;
29454 126 int32_t screenid = SH::get_arg(sarg2, v) / 10000;
29455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( ((unsigned)dmapid) >= MAXDMAPS )
29456 {
29457 Z_scripterrlog("Invalid DMap ID (%d) passed to PitWarp(). Aborting.\n", dmapid);
29458 return;
29459 }
29460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( ((unsigned)screenid) >= MAPSCRS )
29461 {
29462 Z_scripterrlog("Invalid Screen ID (%d) passed to PitWarp(). Aborting.\n", screenid);
29463 return;
29464 }
29465 //Extra sanity guard.
29466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( DMaps[dmapid].map*MAPSCRS+DMaps[dmapid].xoff+screenid >= (int32_t)TheMaps.size() )
29467 {
29468 Z_scripterrlog("Invalid destination passed to Warp(). Aborting.\n");
29469 return;
29470 }
29471 126 tmpscr->sidewarpdmap[0] = dmapid;
29472 126 tmpscr->sidewarpscr[0] = screenid;
29473 126 tmpscr->sidewarptype[0] = wtIWARP;
29474 126 Hero.ffwarp = true;
29475 126 Hero.ffpit = true;
29476 126 }
29477
29478 void do_breakshield()
29479 {
29480 int32_t UID = get_register(sarg1);
29481
29482 for(int32_t j = 0; j < guys.Count(); j++)
29483 if(guys.spr(j)->getUID() == UID)
29484 {
29485 ((enemy*)guys.spr(j))->break_shield();
29486 return;
29487 }
29488 }
29489
29490 void do_showsavescreen()
29491 {
29492 bool didsaved = save_game(false, 0);
29493 set_register(sarg1, didsaved ? 10000 : 0);
29494 }
29495
29496 10848 void do_selectweapon(bool v, int32_t btn)
29497 {
29498
2/4
✓ Branch 0 taken 5268 times.
✓ Branch 1 taken 5580 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10848 switch(btn)
29499 {
29500 case 1:
29501
1/2
✓ Branch 0 taken 5580 times.
✗ Branch 1 not taken.
5580 if(!get_qr(qr_SELECTAWPN))
29502 return;
29503 5580 break;
29504 case 2:
29505 if(!get_qr(qr_SET_XBUTTON_ITEMS))
29506 return;
29507 break;
29508 case 3:
29509 if(!get_qr(qr_SET_YBUTTON_ITEMS))
29510 return;
29511 break;
29512 }
29513
29514 10848 byte dir=(byte)(SH::get_arg(sarg1, v)/10000);
29515
29516 // Selection directions don't match the normal ones...
29517
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
✓ Branch 4 taken 10831 times.
10848 switch(dir)
29518 {
29519 case 0:
29520 dir=SEL_UP;
29521 break;
29522
29523 case 1:
29524 dir=SEL_DOWN;
29525 break;
29526
29527 case 2:
29528 17 dir=SEL_LEFT;
29529 17 break;
29530
29531 case 3:
29532 10831 dir=SEL_RIGHT;
29533 10831 break;
29534
29535 default:
29536 return;
29537 }
29538
29539
2/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5268 times.
✓ Branch 2 taken 5580 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
10848 switch(btn)
29540 {
29541 case 0:
29542 5268 selectNextBWpn(dir);
29543 5268 break;
29544 case 1:
29545 5580 selectNextAWpn(dir);
29546 5580 break;
29547 case 2:
29548 selectNextXWpn(dir);
29549 break;
29550 case 3:
29551 selectNextYWpn(dir);
29552 break;
29553 }
29554 10848 }
29555
29556 ///----------------------------------------------------------------------------------------------------//
29557 //Screen Information
29558
29559 16271098 void do_issolid()
29560 {
29561 16271098 int32_t x = int32_t(ri->d[rINDEX] / 10000);
29562 16271098 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
29563
29564 16271098 set_register(sarg1, (_walkflag(x, y, 1) ? 10000 : 0));
29565 16271098 }
29566
29567 void do_mapdataissolid()
29568 {
29569 if ( ri->mapsref == MAX_SIGNED_32 )
29570 {
29571 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","isSolid()");
29572 set_register(sarg1,10000);
29573 }
29574 else
29575 {
29576 //mapscr *m = GetMapscr(ri->mapsref);
29577 int32_t x = int32_t(ri->d[rINDEX] / 10000);
29578 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
29579 switch(ri->mapsref)
29580 {
29581 case MAPSCR_TEMP0:
29582 set_register(sarg1, (_walkflag(x, y, 1)) ? 10000 : 0);
29583 break;
29584 case MAPSCR_SCROLL0:
29585 set_register(sarg1, (_walkflag(x, y, 1, FFCore.ScrollingScreens[0], FFCore.ScrollingScreens[1], FFCore.ScrollingScreens[2])) ? 10000 : 0);
29586 break;
29587 default:
29588 set_register(sarg1, (_walkflag(x, y, 1, GetMapscr(ri->mapsref)) ? 10000 : 0));
29589 }
29590 }
29591 }
29592
29593 void do_mapdataissolid_layer()
29594 {
29595 if ( ri->mapsref == MAX_SIGNED_32 )
29596 {
29597 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","isSolidLayer()");
29598 set_register(sarg1,10000);
29599 }
29600 else
29601 {
29602 //mapscr *m = GetMapscr(ri->mapsref);
29603 int32_t x = int32_t(ri->d[rINDEX] / 10000);
29604 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
29605 int32_t layer = int32_t(ri->d[rEXP1] / 10000);
29606 if(BC::checkBounds(layer, 0, 6, "mapdata->isSolidLayer()") != SH::_NoError)
29607 {
29608 set_register(sarg1,10000);
29609 }
29610 else
29611 {
29612 switch(ri->mapsref)
29613 {
29614 case MAPSCR_TEMP0:
29615 set_register(sarg1, (_walkflag_layer(x, y, 1, FFCore.tempScreens[layer])) ? 10000 : 0);
29616 break;
29617 case MAPSCR_SCROLL0:
29618 set_register(sarg1, (_walkflag_layer(x, y, 1, FFCore.ScrollingScreens[layer])) ? 10000 : 0);
29619 break;
29620 default:
29621 mapscr* m = GetMapscr(ri->mapsref);
29622 if(layer > 0)
29623 {
29624 if(m->layermap[layer] == 0)
29625 {
29626 set_register(sarg1,10000);
29627 break;
29628 }
29629 m = &TheMaps[(m->layermap[layer]*MAPSCRS + m->layerscreen[layer])];
29630 }
29631 set_register(sarg1, (_walkflag_layer(x, y, 1, m) ? 10000 : 0));
29632 break;
29633 }
29634 }
29635 }
29636 }
29637
29638 void do_issolid_layer()
29639 {
29640 int32_t x = int32_t(ri->d[rINDEX] / 10000);
29641 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
29642 int32_t layer = int32_t(ri->d[rEXP1] / 10000);
29643 if(BC::checkBounds(layer, 0, 6, "Screen->isSolidLayer()") != SH::_NoError)
29644 {
29645 set_register(sarg1,10000);
29646 }
29647 else
29648 {
29649 set_register(sarg1, (_walkflag_layer(x, y, 1, FFCore.tempScreens[layer])) ? 10000 : 0);
29650 }
29651 }
29652
29653 249 void do_setsidewarp()
29654 {
29655 249 int32_t warp = SH::read_stack(ri->sp + 3) / 10000;
29656 249 int32_t scrn = SH::read_stack(ri->sp + 2) / 10000;
29657 249 int32_t dmap = SH::read_stack(ri->sp + 1) / 10000;
29658 249 int32_t type = SH::read_stack(ri->sp + 0) / 10000;
29659
29660
2/4
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
498 if(BC::checkBounds(warp, -1, 3, "Screen->SetSideWarp") != SH::_NoError ||
29661
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 BC::checkBounds(scrn, -1, 0x87, "Screen->SetSideWarp") != SH::_NoError ||
29662
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 BC::checkBounds(dmap, -1, MAXDMAPS - 1, "Screen->SetSideWarp") != SH::_NoError ||
29663 249 BC::checkBounds(type, -1, wtMAX - 1, "Screen->SetSideWarp") != SH::_NoError)
29664 return;
29665
29666
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(scrn > -1)
29667 249 tmpscr->sidewarpscr[warp] = scrn;
29668
29669
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(dmap > -1)
29670 249 tmpscr->sidewarpdmap[warp] = dmap;
29671
29672
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(type > -1)
29673 249 tmpscr->sidewarptype[warp] = type;
29674 249 }
29675
29676 5 void do_settilewarp()
29677 {
29678 5 int32_t warp = SH::read_stack(ri->sp + 3) / 10000;
29679 5 int32_t scrn = SH::read_stack(ri->sp + 2) / 10000;
29680 5 int32_t dmap = SH::read_stack(ri->sp + 1) / 10000;
29681 5 int32_t type = SH::read_stack(ri->sp + 0) / 10000;
29682
29683
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
10 if(BC::checkBounds(warp, -1, 3, "Screen->SetTileWarp") != SH::_NoError ||
29684
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 BC::checkBounds(scrn, -1, 0x87, "Screen->SetTileWarp") != SH::_NoError ||
29685
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 BC::checkBounds(dmap, -1, MAXDMAPS - 1, "Screen->SetTileWarp") != SH::_NoError ||
29686 5 BC::checkBounds(type, -1, wtMAX - 1, "Screen->SetTileWarp") != SH::_NoError)
29687 return;
29688
29689
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(scrn > -1)
29690 5 tmpscr->tilewarpscr[warp] = scrn;
29691
29692
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(dmap > -1)
29693 5 tmpscr->tilewarpdmap[warp] = dmap;
29694
29695
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(type > -1)
29696 5 tmpscr->tilewarptype[warp] = type;
29697 5 }
29698
29699 354940 void do_getsidewarpdmap(const bool v)
29700 {
29701 354940 int32_t warp = SH::get_arg(sarg1, v) / 10000;
29702
29703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354940 times.
354940 if(BC::checkBounds(warp, -1, 3, "Screen->GetSideWarpDMap") != SH::_NoError)
29704 {
29705 set_register(sarg1, -10000);
29706 return;
29707 }
29708
29709 354940 set_register(sarg1, tmpscr->sidewarpdmap[warp]*10000);
29710 354940 }
29711
29712 void do_getsidewarpscr(const bool v)
29713 {
29714 int32_t warp = SH::get_arg(sarg1, v) / 10000;
29715
29716 if(BC::checkBounds(warp, -1, 3, "Screen->GetSideWarpScreen") != SH::_NoError)
29717 {
29718 set_register(sarg1, -10000);
29719 return;
29720 }
29721
29722 set_register(sarg1, tmpscr->sidewarpscr[warp]*10000);
29723 }
29724
29725 void do_getsidewarptype(const bool v)
29726 {
29727 int32_t warp = SH::get_arg(sarg1, v) / 10000;
29728
29729 if(BC::checkBounds(warp, -1, 3, "Screen->GetSideWarpType") != SH::_NoError)
29730 {
29731 set_register(sarg1, -10000);
29732 return;
29733 }
29734
29735 set_register(sarg1, tmpscr->sidewarptype[warp]*10000);
29736 }
29737
29738 354943 void do_gettilewarpdmap(const bool v)
29739 {
29740 354943 int32_t warp = SH::get_arg(sarg1, v) / 10000;
29741
29742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354943 times.
354943 if(BC::checkBounds(warp, -1, 3, "Screen->GetTileWarpDMap") != SH::_NoError)
29743 {
29744 set_register(sarg1, -10000);
29745 return;
29746 }
29747
29748 354943 set_register(sarg1, tmpscr->tilewarpdmap[warp]*10000);
29749 354943 }
29750
29751 3 void do_gettilewarpscr(const bool v)
29752 {
29753 3 int32_t warp = SH::get_arg(sarg1, v) / 10000;
29754
29755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(BC::checkBounds(warp, -1, 3, "Screen->GetTileWarpScreen") != SH::_NoError)
29756 {
29757 set_register(sarg1, -10000);
29758 return;
29759 }
29760
29761 3 set_register(sarg1, tmpscr->tilewarpscr[warp]*10000);
29762 3 }
29763
29764 3 void do_gettilewarptype(const bool v)
29765 {
29766 3 int32_t warp = SH::get_arg(sarg1, v) / 10000;
29767
29768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(BC::checkBounds(warp, -1, 3, "Screen->GetTileWarpType") != SH::_NoError)
29769 {
29770 set_register(sarg1, -10000);
29771 return;
29772 }
29773
29774 3 set_register(sarg1, tmpscr->tilewarptype[warp]*10000);
29775 3 }
29776
29777 12696160 void do_layerscreen()
29778 {
29779 12696160 int32_t layer = (get_register(sarg2) / 10000) - 1;
29780
29781
3/4
✓ Branch 0 taken 12696160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10821826 times.
✓ Branch 3 taken 1874334 times.
12696160 if(BC::checkBounds(layer, 0, 5, "Screen->LayerScreen") != SH::_NoError ||
29782 12696160 tmpscr->layermap[layer] == 0)
29783 1874334 set_register(sarg1, -10000);
29784 else
29785 10821826 set_register(sarg1, tmpscr->layerscreen[layer] * 10000);
29786 12696160 }
29787
29788 16038753 void do_layermap()
29789 {
29790 16038753 int32_t layer = (get_register(sarg2) / 10000) - 1;
29791
29792
3/4
✓ Branch 0 taken 16038753 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13868561 times.
✓ Branch 3 taken 2170192 times.
16038753 if(BC::checkBounds(layer, 0, 5, "Screen->LayerMap") != SH::_NoError ||
29793 16038753 tmpscr->layermap[layer] == 0)
29794 2170192 set_register(sarg1, -10000);
29795 else
29796 13868561 set_register(sarg1, tmpscr->layermap[layer] * 10000);
29797 16038753 }
29798
29799
29800
29801
29802 60 void do_triggersecrets()
29803 {
29804 60 hidden_entrance(0, true, false, -4);
29805 //hidden_entrance(0,true,single16,scombo);
29806 //bool findentrance(int32_t x, int32_t y, int32_t flag, bool setflag)
29807 //We need a variation on these that triggers any combos with a given flag. -Z
29808 60 }
29809
29810
29811
29812
29813 void do_getscreenflags()
29814 {
29815 int32_t map = (ri->d[rEXP1] / 10000) - 1;
29816 int32_t scrn = ri->d[rINDEX2] / 10000;
29817 int32_t flagset = ri->d[rINDEX] / 10000;
29818
29819 if(BC::checkMapID(map, "Game->GetScreenFlags") != SH::_NoError ||
29820 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenFlags") != SH::_NoError ||
29821 BC::checkBounds(flagset, 0, 9, "Game->GetScreenFlags") != SH::_NoError)
29822 return;
29823
29824 set_register(sarg1, get_screenflags(&TheMaps[map * MAPSCRS + scrn], flagset));
29825 }
29826
29827 void do_getscreeneflags()
29828 {
29829 int32_t map = (ri->d[rEXP1] / 10000) - 1;
29830 int32_t scrn = ri->d[rINDEX2] / 10000;
29831 int32_t flagset = ri->d[rINDEX] / 10000;
29832
29833 if(BC::checkMapID(map, "Game->GetScreenEFlags") != SH::_NoError ||
29834 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEFlags") != SH::_NoError ||
29835 BC::checkBounds(flagset, 0, 9, "Game->GetScreenEFlags") != SH::_NoError)
29836 return;
29837
29838 set_register(sarg1, get_screeneflags(&TheMaps[map * MAPSCRS + scrn], flagset));
29839 }
29840
29841 void FFScript::do_graphics_getpixel()
29842 {
29843 int32_t yoffset = 0;
29844 const bool brokenOffset= ( (get_er(er_BITMAPOFFSET)!=0) || (get_qr(qr_BITMAPOFFSETFIX)!=0) );
29845 int32_t ref = (ri->d[rEXP1]);
29846
29847 if ( ref == -10000 || ref == -20000 || ref >= 10000 ) //Bitmaps Loaded by LoadBitmapID have values of -10000 to 70000
29848 {
29849 ref /= 10000;
29850 }
29851 else ref -= 10; //Bitmaps other than those loaded by LoadBitmapID
29852
29853 BITMAP *bitty = FFCore.GetScriptBitmap(ref);
29854 int32_t xpos = ri->d[rINDEX2] / 10000;
29855
29856 if(!brokenOffset && ref == -1 )
29857 {
29858 yoffset = 56; //should this be -56?
29859 }
29860 else
29861 {
29862 yoffset = 0;
29863 }
29864
29865 int32_t ypos = (ri->d[rINDEX] / 10000)+yoffset;
29866 if(!bitty)
29867 {
29868 bitty = scrollbuf;
29869 }
29870
29871 int32_t ret = getpixel(bitty, xpos, ypos); //This is a palette index value.
29872
29873 if(!get_qr(qr_BROKEN_GETPIXEL_VALUE))
29874 ret *= 10000;
29875 set_register(sarg1, ret);
29876 }
29877
29878 //Some of these need to be reduced to two inputs. -Z
29879
29880 int32_t get_screendoor(mapscr *m, int32_t d)
29881 {
29882 int32_t f = m->door[d];
29883 return f*10000;
29884 }
29885
29886
29887
29888 int32_t get_screenlayeropacity(mapscr *m, int32_t d)
29889 {
29890 int32_t f = m->layeropacity[d]; //6 of these
29891 return f*10000;
29892 }
29893
29894 int32_t get_screensecretcombo(mapscr *m, int32_t d)
29895 {
29896 int32_t f = m->secretcombo[d]; //128 of these
29897 return f*10000;
29898 }
29899
29900 int32_t get_screensecretcset(mapscr *m, int32_t d)
29901 {
29902 int32_t f = m->secretcset[d]; //128 of these
29903 return f*10000;
29904 }
29905
29906 int32_t get_screensecretflag(mapscr *m, int32_t d)
29907 {
29908 int32_t f = m->secretflag[d]; //128 of these
29909 return f*10000;
29910 }
29911
29912 int32_t get_screenlayermap(mapscr *m, int32_t d)
29913 {
29914 int32_t f = m->layermap[d]; //6 of these
29915 return f*10000;
29916 }
29917
29918 int32_t get_screenlayerscreen(mapscr *m, int32_t d)
29919 {
29920 int32_t f = m->layerscreen[d]; //6 of these
29921 return f*10000;
29922 }
29923
29924 int32_t get_screenpath(mapscr *m, int32_t d)
29925 {
29926 int32_t f = m->path[d]; //4 of these
29927 return f*10000;
29928 }
29929
29930 int32_t get_screenwarpReturnX(mapscr *m, int32_t d)
29931 {
29932 int32_t f = m->warpreturnx[d]; //4 of these
29933 return f*10000;
29934 }
29935
29936 int32_t get_screenwarpReturnY(mapscr *m, int32_t d)
29937 {
29938 int32_t f = m->warpreturny[d]; //4 of these
29939 return f*10000;
29940 }
29941 //One too many inputs here. -Z
29942 int32_t get_screenGuy(mapscr *m)
29943 {
29944 int32_t f = m->guy;
29945 return f*10000;
29946 }
29947 //One too many inputs here. -Z
29948 int32_t get_screenString(mapscr *m)
29949 {
29950 int32_t f = m->str;
29951 return f*10000;
29952 }
29953 //One too many inputs here. -Z
29954 int32_t get_screenRoomtype(mapscr *m)
29955 {
29956 int32_t f = m->room;
29957 return f*10000;
29958 }
29959 //One too many inputs here. -Z
29960 int32_t get_screenEntryX(mapscr *m)
29961 {
29962 int32_t f = m->entry_x;
29963 return f*10000;
29964 }
29965 //One too many inputs here. -Z
29966 int32_t get_screenEntryY(mapscr *m)
29967 {
29968 int32_t f = m->entry_y;
29969 return f*10000;
29970 }
29971 //One too many inputs here. -Z
29972 int32_t get_screenitem(mapscr *m)
29973 {
29974 int32_t f = m->item;
29975 return f*10000;
29976 }
29977 //One too many inputs here. -Z
29978 int32_t get_screenundercombo(mapscr *m)
29979 {
29980 int32_t f = m->undercombo;
29981 return f*10000;
29982 }
29983 //One too many inputs here. -Z
29984 int32_t get_screenundercset(mapscr *m)
29985 {
29986 int32_t f = m->undercset;
29987 return f*10000;
29988 }
29989 //One too many inputs here. -Z
29990 int32_t get_screenatchall(mapscr *m)
29991 {
29992 int32_t f = m->catchall;
29993 return f*10000;
29994 }
29995 void do_getscreenLayerOpacity()
29996 {
29997 int32_t map = (ri->d[rEXP1] / 10000) - 1;
29998 int32_t scrn = ri->d[rINDEX2] / 10000;
29999 int32_t d = ri->d[rINDEX] / 10000;
30000
30001 if(BC::checkMapID(map, "Game->GetLayerOpacity(...map...)") != SH::_NoError ||
30002 BC::checkBounds(scrn, 0, 0x87, "Game->GetLayerOpacity(...screen...)") != SH::_NoError ||
30003 BC::checkBounds(d, 0, 6, "Game->GetLayerOpacity(...val...)") != SH::_NoError)
30004 return;
30005
30006 set_register(sarg1, get_screenlayeropacity(&TheMaps[map * MAPSCRS + scrn], d));
30007 }
30008 void do_getscreenSecretCombo()
30009 {
30010 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30011 int32_t scrn = ri->d[rINDEX2] / 10000;
30012 int32_t d = ri->d[rINDEX] / 10000;
30013
30014 if(BC::checkMapID(map, "Game->GetSecretCombo(...map...)") != SH::_NoError ||
30015 BC::checkBounds(scrn, 0, 0x87, "Game->GetSecretCombo(...screen...)") != SH::_NoError ||
30016 BC::checkBounds(d, 0, 127, "Game->GetSecretCombo(...val...)") != SH::_NoError)
30017 return;
30018
30019 set_register(sarg1, get_screensecretcombo(&TheMaps[map * MAPSCRS + scrn], d));
30020 }
30021
30022 void do_getscreenSecretCSet()
30023 {
30024 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30025 int32_t scrn = ri->d[rINDEX2] / 10000;
30026 int32_t d = ri->d[rINDEX] / 10000;
30027
30028 if(BC::checkMapID(map, "Game->GetSecretCSet(...map...)") != SH::_NoError ||
30029 BC::checkBounds(scrn, 0, 0x87, "Game->GetSecretCSet(...screen...)") != SH::_NoError ||
30030 BC::checkBounds(d, 0, 127, "Game->GetSecretCSet(...val...)") != SH::_NoError)
30031 return;
30032
30033 set_register(sarg1, get_screensecretcset(&TheMaps[map * MAPSCRS + scrn], d));
30034 }
30035
30036 void do_getscreenSecretFlag()
30037 {
30038 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30039 int32_t scrn = ri->d[rINDEX2] / 10000;
30040 int32_t d = ri->d[rINDEX] / 10000;
30041
30042 if(BC::checkMapID(map, "Game->GetSecretFlag(...map...)") != SH::_NoError ||
30043 BC::checkBounds(scrn, 0, 0x87, "Game->GetSecretFlag(...screen...)") != SH::_NoError ||
30044 BC::checkBounds(d, 0,127, "Game->GetSecretFlag(...val...)") != SH::_NoError)
30045 return;
30046
30047 set_register(sarg1, get_screensecretflag(&TheMaps[map * MAPSCRS + scrn], d));
30048 }
30049 void do_getscreenLayerMap()
30050 {
30051 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30052 int32_t scrn = ri->d[rINDEX2] / 10000;
30053 int32_t d = ri->d[rINDEX] / 10000;
30054
30055 if(BC::checkMapID(map, "Game->GetSreenLayerMap(...map...)") != SH::_NoError ||
30056 BC::checkBounds(scrn, 0, 0x87, "Game->GetSreenLayerMap(...screen...)") != SH::_NoError ||
30057 BC::checkBounds(d, 0, 6, "Game->GetSreenLayerMap(...val...)") != SH::_NoError)
30058 return;
30059
30060 set_register(sarg1, get_screenlayermap(&TheMaps[map * MAPSCRS + scrn], d));
30061 }
30062 void do_getscreenLayerscreen()
30063 {
30064 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30065 int32_t scrn = ri->d[rINDEX2] / 10000;
30066 int32_t d = ri->d[rINDEX] / 10000;
30067
30068 if(BC::checkMapID(map, "Game->GetSreenLayerScreen(...map...)") != SH::_NoError ||
30069 BC::checkBounds(scrn, 0, 0x87, "Game->GetSreenLayerScreen(...screen...)") != SH::_NoError ||
30070 BC::checkBounds(d, 0, 6, "Game->GetSreenLayerScreen(...val...)") != SH::_NoError)
30071 return;
30072
30073 set_register(sarg1, get_screenlayerscreen(&TheMaps[map * MAPSCRS + scrn], d));
30074 }
30075 void do_getscreenPath()
30076 {
30077 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30078 int32_t scrn = ri->d[rINDEX2] / 10000;
30079 int32_t d = ri->d[rINDEX] / 10000;
30080
30081 if(BC::checkMapID(map, "Game->GetSreenPath(...map...)") != SH::_NoError ||
30082 BC::checkBounds(scrn, 0, 0x87, "Game->GetSreenPath(...screen...)") != SH::_NoError ||
30083 BC::checkBounds(d, 0, 3, "Game->GetSreenPath(...val...)") != SH::_NoError)
30084 return;
30085
30086 set_register(sarg1, get_screenpath(&TheMaps[map * MAPSCRS + scrn], d));
30087 }
30088 void do_getscreenWarpReturnX()
30089 {
30090 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30091 int32_t scrn = ri->d[rINDEX2] / 10000;
30092 int32_t d = ri->d[rINDEX] / 10000;
30093
30094 if(BC::checkMapID(map, "Game->GetScreenWarpReturnX(...map...)") != SH::_NoError ||
30095 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenWarpReturnX(...screen...)") != SH::_NoError ||
30096 BC::checkBounds(d, 0, 3, "Game->GetScreenWarpReturnX(...val...)") != SH::_NoError)
30097 return;
30098
30099 set_register(sarg1, get_screenwarpReturnX(&TheMaps[map * MAPSCRS + scrn], d));
30100 }
30101 void do_getscreenWarpReturnY()
30102 {
30103 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30104 int32_t scrn = ri->d[rINDEX2] / 10000;
30105 int32_t d = ri->d[rINDEX] / 10000;
30106
30107 if(BC::checkMapID(map, "Game->GetScreenWarpReturnY(...map...)") != SH::_NoError ||
30108 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenWarpReturnY(...screen...)") != SH::_NoError ||
30109 BC::checkBounds(d, 0, 3, "Game->GetScreenWarpReturnY(...val...)") != SH::_NoError)
30110 return;
30111
30112 set_register(sarg1, get_screenwarpReturnY(&TheMaps[map * MAPSCRS + scrn], d));
30113 }
30114
30115 /*
30116 //One too many inputs here. -Z
30117 void do_getscreenatchall()
30118 {
30119 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30120 int32_t scrn = ri->d[rINDEX2] / 10000;
30121 int32_t d = ri->d[rINDEX] / 10000;
30122
30123 if(BC::checkMapID(map, "Game->GetScreenCatchall(...map...)") != SH::_NoError ||
30124 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenCatchall(...screen...)") != SH::_NoError ||
30125 BC::checkBounds(d, 0, 6, "Game->GetScreenCatchall(...val...)") != SH::_NoError)
30126 return;
30127
30128 set_register(sarg1, get_screenatchall(&TheMaps[map * MAPSCRS + scrn], d));
30129 }
30130
30131
30132 //One too many inputs here. -Z
30133 void do_getscreenUndercombo()
30134 {
30135 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30136 int32_t scrn = ri->d[rINDEX2] / 10000;
30137 int32_t d = ri->d[rINDEX] / 10000;
30138
30139 if(BC::checkMapID(map, "Game->GetcreenUndercombo(...map...)") != SH::_NoError ||
30140 BC::checkBounds(scrn, 0, 0x87, "Game->GetcreenUndercombo(...screen...)") != SH::_NoError ||
30141 BC::checkBounds(d, 0, 6, "Game->GetcreenUndercombo(...val...)") != SH::_NoError)
30142 return;
30143
30144 set_register(sarg1, get_screenundercombo(&TheMaps[map * MAPSCRS + scrn], d));
30145 }
30146 //One too many inputs here. -Z
30147 void do_getscreenUnderCSet()
30148 {
30149 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30150 int32_t scrn = ri->d[rINDEX2] / 10000;
30151 int32_t d = ri->d[rINDEX] / 10000;
30152
30153 if(BC::checkMapID(map, "Game->GeScreenUnderCSet(...map...)") != SH::_NoError ||
30154 BC::checkBounds(scrn, 0, 0x87, "Game->GeScreenUnderCSet(...screen...)") != SH::_NoError ||
30155 BC::checkBounds(d, 0, 6, "Game->GeScreenUnderCSet(...val...)") != SH::_NoError)
30156 return;
30157
30158 set_register(sarg1, get_screenundercset(&TheMaps[map * MAPSCRS + scrn], d));
30159 }
30160
30161 //One too many inputs here. -Z
30162 void do_getscreenGuy()
30163 {
30164 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30165 int32_t scrn = ri->d[rINDEX2] / 10000;
30166 int32_t d = ri->d[rINDEX] / 10000;
30167
30168 if(BC::checkMapID(map, "Game->GetScreenGuy(...map...)") != SH::_NoError ||
30169 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenGuy(...screen...)") != SH::_NoError ||
30170 BC::checkBounds(d, 0, 214747, "Game->GetScreenGuy(...val...)") != SH::_NoError)
30171 return;
30172
30173 set_register(sarg1, get_screenGuy(&TheMaps[map * MAPSCRS + scrn], d));
30174 }
30175 //One too many inputs here. -Z
30176 void do_getscreenString()
30177 {
30178 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30179 int32_t scrn = ri->d[rINDEX2] / 10000;
30180 int32_t d = ri->d[rINDEX] / 10000;
30181
30182 if(BC::checkMapID(map, "Game->GetScreenString(...map...)") != SH::_NoError ||
30183 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenString(...screen...)") != SH::_NoError ||
30184 BC::checkBounds(d, 0, 214747, "Game->GetScreenString(...val...)") != SH::_NoError)
30185 return;
30186
30187 set_register(sarg1, get_screenString(&TheMaps[map * MAPSCRS + scrn], d));
30188 }
30189 //One too many inputs here. -Z
30190 void do_getscreenRoomType()
30191 {
30192 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30193 int32_t scrn = ri->d[rINDEX2] / 10000;
30194 int32_t d = ri->d[rINDEX] / 10000;
30195
30196 if(BC::checkMapID(map, "Game->GetScreenRoomType(...map...)") != SH::_NoError ||
30197 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenRoomType(...screen...)") != SH::_NoError ||
30198 BC::checkBounds(d, 0, 214747, "Game->GetScreenRoomType(...val...)") != SH::_NoError)
30199 return;
30200
30201 set_register(sarg1, get_screenRoomtype(&TheMaps[map * MAPSCRS + scrn], d));
30202 }
30203 //One too many inputs here. -Z
30204 void do_getscreenEntryX()
30205 {
30206 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30207 int32_t scrn = ri->d[rINDEX2] / 10000;
30208 int32_t d = ri->d[rINDEX] / 10000;
30209
30210 if(BC::checkMapID(map, "Game->GetScreenEntryX(...map...)") != SH::_NoError ||
30211 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEntryX(...screen...)") != SH::_NoError ||
30212 BC::checkBounds(d, 0, 214747, "Game->GetScreenEntryX(...val...)") != SH::_NoError)
30213 return;
30214
30215 set_register(sarg1, get_screenEntryX(&TheMaps[map * MAPSCRS + scrn], d));
30216 }
30217 //One too many inputs here. -Z
30218 void do_getscreenEntryY()
30219 {
30220 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30221 int32_t scrn = ri->d[rINDEX2] / 10000;
30222 int32_t d = ri->d[rINDEX] / 10000;
30223
30224 if(BC::checkMapID(map, "Game->GetScreenEntryY(...map...)") != SH::_NoError ||
30225 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEntryY(...screen...)") != SH::_NoError ||
30226 BC::checkBounds(d, 0, 214747, "Game->GetScreenEntryY(...val...)") != SH::_NoError)
30227 return;
30228
30229 set_register(sarg1, get_screenEntryY(&TheMaps[map * MAPSCRS + scrn], d));
30230 }
30231 //One too many inputs here. -Z
30232 void do_getscreenItem()
30233 {
30234 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30235 int32_t scrn = ri->d[rINDEX2] / 10000;
30236 int32_t d = ri->d[rINDEX] / 10000;
30237
30238 if(BC::checkMapID(map, "Game->GetScreenItem(...map...)") != SH::_NoError ||
30239 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenItem(...screen...)") != SH::_NoError ||
30240 BC::checkBounds(d, 0, 255, "Game->GetScreenItem(...val...)") != SH::_NoError)
30241 return;
30242
30243 set_register(sarg1, get_screenitem(&TheMaps[map * MAPSCRS + scrn], d));
30244 }
30245 */
30246 void do_getscreendoor()
30247 {
30248 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30249 int32_t scrn = ri->d[rINDEX2] / 10000;
30250 int32_t door = ri->d[rINDEX] / 10000;
30251
30252 if(BC::checkMapID(map, "Game->GetScreenDoor(...map...)") != SH::_NoError ||
30253 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenDoor(...screen...)") != SH::_NoError ||
30254 BC::checkBounds(door, 0, 3, "Game->GetScreenDoor(...doorindex...)") != SH::_NoError)
30255 return;
30256
30257 set_register(sarg1, get_screendoor(&TheMaps[map * MAPSCRS + scrn], door));
30258 }
30259
30260 int32_t get_screennpc(mapscr *m, int32_t index)
30261 {
30262 int32_t f = m->enemy[index];
30263 return f*10000;
30264 }
30265
30266
30267 void do_getscreennpc()
30268 {
30269 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30270 int32_t scrn = ri->d[rINDEX2] / 10000;
30271 int32_t enemy = ri->d[rINDEX] / 10000;
30272
30273 if(BC::checkMapID(map, "Game->GetScreenEnemy(...map...)") != SH::_NoError ||
30274 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEnemy(...screen...)") != SH::_NoError ||
30275 BC::checkBounds(enemy, 0, 9, "Game->GetScreenEnemy(...enemy...)") != SH::_NoError)
30276 return;
30277
30278 set_register(sarg1, get_screennpc(&TheMaps[map * MAPSCRS + scrn], enemy));
30279 }
30280
30281
30282 ///----------------------------------------------------------------------------------------------------//
30283 //Pointer handling
30284
30285 4 void do_isvalidarray()
30286 {
30287 4 int32_t ptr = get_register(sarg1)/10000;
30288
30289 4 set_register(sarg1,0);
30290
30291
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!ptr) return;
30292
30293
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(ptr < 0) //An object array?
30294 {
30295 int32_t objptr = -ptr;
30296 auto it = objectRAM.find(objptr);
30297 if(it == objectRAM.end())
30298 return;
30299 set_register(sarg1,10000);
30300 }
30301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 else if(ptr >= NUM_ZSCRIPT_ARRAYS) //check global
30302 {
30303 dword gptr = ptr - NUM_ZSCRIPT_ARRAYS;
30304
30305 if(gptr > game->globalRAM.size())
30306 return;
30307 else set_register(sarg1,game->globalRAM[gptr].Valid() ? 10000 : 0);
30308 }
30309 else
30310 {
30311 4 set_register(sarg1,localRAM[ptr].Valid() ? 10000 : 0);
30312 }
30313 4 }
30314
30315 27033 void do_isvaliditem()
30316 {
30317 27033 int32_t IID = get_register(sarg1);
30318 //int32_t ct = items.Count();
30319
30320 //for ( int32_t j = items.Count()-1; j >= 0; --j )
30321
2/2
✓ Branch 0 taken 30321 times.
✓ Branch 1 taken 203 times.
30524 for(int32_t j = 0; j < items.Count(); j++)
30322 //for(int32_t j = 0; j < ct; j++)
30323
2/2
✓ Branch 0 taken 26830 times.
✓ Branch 1 taken 3491 times.
30321 if(items.spr(j)->getUID() == IID)
30324 {
30325 26830 set_register(sarg1, 10000);
30326 26830 return;
30327 }
30328
30329 203 set_register(sarg1, 0);
30330 27033 }
30331
30332 6266198 void do_isvalidnpc()
30333 {
30334 6266198 int32_t UID = get_register(sarg1);
30335 //for ( int32_t j = guys.Count()-1; j >= 0; --j )
30336 //int32_t ct = guys.Count();
30337
30338
2/2
✓ Branch 0 taken 20581357 times.
✓ Branch 1 taken 99922 times.
20681279 for(int32_t j = 0; j < guys.Count(); j++)
30339 //for(int32_t j = 0; j < ct; j++)
30340
2/2
✓ Branch 0 taken 6166276 times.
✓ Branch 1 taken 14415081 times.
20581357 if(guys.spr(j)->getUID() == UID)
30341 {
30342 6166276 set_register(sarg1, 10000);
30343 6166276 return;
30344 }
30345
30346 99922 set_register(sarg1, 0);
30347 6266198 }
30348
30349 593592 void do_isvalidlwpn()
30350 {
30351 593592 int32_t WID = get_register(sarg1);
30352 //int32_t ct = Lwpns.Count();
30353
30354 //for ( int32_t j = Lwpns.Count()-1; j >= 0; --j )
30355
2/2
✓ Branch 0 taken 2892378 times.
✓ Branch 1 taken 47556 times.
2939934 for(int32_t j = 0; j < Lwpns.Count(); j++)
30356 //for(int32_t j = 0; j < ct; j++)
30357
2/2
✓ Branch 0 taken 546036 times.
✓ Branch 1 taken 2346342 times.
2892378 if(Lwpns.spr(j)->getUID() == WID)
30358 {
30359 546036 set_register(sarg1, 10000);
30360 546036 return;
30361 }
30362
30363 47556 set_register(sarg1, 0);
30364 593592 }
30365
30366 122622 void do_isvalidewpn()
30367 {
30368 122622 int32_t WID = get_register(sarg1);
30369 // int32_t ct = Ewpns.Count();
30370
30371 // for ( int32_t j = Ewpns.Count()-1; j >= 0; --j )
30372
2/2
✓ Branch 0 taken 596698 times.
✓ Branch 1 taken 23727 times.
620425 for(int32_t j = 0; j < Ewpns.Count(); j++)
30373 //for(int32_t j = 0; j < ct; j++)
30374
2/2
✓ Branch 0 taken 98895 times.
✓ Branch 1 taken 497803 times.
596698 if(Ewpns.spr(j)->getUID() == WID)
30375 {
30376 98895 set_register(sarg1, 10000);
30377 98895 return;
30378 }
30379
30380 23727 set_register(sarg1, 0);
30381 122622 }
30382
30383 void do_lwpnmakeangular()
30384 {
30385 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->MakeAngular") == SH::_NoError)
30386 {
30387 if (!LwpnH::getWeapon()->angular)
30388 {
30389 double vx;
30390 double vy;
30391 switch(NORMAL_DIR(LwpnH::getWeapon()->dir))
30392 {
30393 case l_up:
30394 case l_down:
30395 case left:
30396 vx = -1.0*((weapon*)s)->step;
30397 break;
30398 case r_down:
30399 case r_up:
30400 case right:
30401 vx = ((weapon*)s)->step;
30402 break;
30403
30404 default:
30405 vx = 0;
30406 break;
30407 }
30408 switch(NORMAL_DIR(LwpnH::getWeapon()->dir))
30409 {
30410 case l_up:
30411 case r_up:
30412 case up:
30413 vy = -1.0*((weapon*)s)->step;
30414 break;
30415 case l_down:
30416 case r_down:
30417 case down:
30418 vy = ((weapon*)s)->step;
30419 break;
30420
30421 default:
30422 vy = 0;
30423 break;
30424 }
30425 LwpnH::getWeapon()->angular = true;
30426 LwpnH::getWeapon()->angle=atan2(vy, vx);
30427 LwpnH::getWeapon()->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
30428 LwpnH::getWeapon()->doAutoRotate();
30429 }
30430 }
30431 }
30432
30433 void do_lwpnmakedirectional()
30434 {
30435 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->MakeDirectional") == SH::_NoError)
30436 {
30437 if (LwpnH::getWeapon()->angular)
30438 {
30439 LwpnH::getWeapon()->dir = NORMAL_DIR(AngleToDir(WrapAngle(LwpnH::getWeapon()->angle)));
30440 LwpnH::getWeapon()->angular = false;
30441 LwpnH::getWeapon()->doAutoRotate(true);
30442 }
30443 }
30444 }
30445
30446 void do_ewpnmakeangular()
30447 {
30448 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->MakeAngular") == SH::_NoError)
30449 {
30450 if (!EwpnH::getWeapon()->angular)
30451 {
30452 double vx;
30453 double vy;
30454 switch(NORMAL_DIR(EwpnH::getWeapon()->dir))
30455 {
30456 case l_up:
30457 case l_down:
30458 case left:
30459 vx = -1.0*((weapon*)s)->step;
30460 break;
30461 case r_down:
30462 case r_up:
30463 case right:
30464 vx = ((weapon*)s)->step;
30465 break;
30466
30467 default:
30468 vx = 0;
30469 break;
30470 }
30471 switch(NORMAL_DIR(EwpnH::getWeapon()->dir))
30472 {
30473 case l_up:
30474 case r_up:
30475 case up:
30476 vy = -1.0*((weapon*)s)->step;
30477 break;
30478 case l_down:
30479 case r_down:
30480 case down:
30481 vy = ((weapon*)s)->step;
30482 break;
30483
30484 default:
30485 vy = 0;
30486 break;
30487 }
30488 EwpnH::getWeapon()->angular = true;
30489 EwpnH::getWeapon()->angle=atan2(vy, vx);
30490 EwpnH::getWeapon()->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
30491 EwpnH::getWeapon()->doAutoRotate();
30492 }
30493 }
30494 }
30495
30496 void do_ewpnmakedirectional()
30497 {
30498 if(EwpnH::loadWeapon(ri->lwpn, "eweapon->MakeDirectional") == SH::_NoError)
30499 {
30500 if (EwpnH::getWeapon()->angular)
30501 {
30502 EwpnH::getWeapon()->dir = NORMAL_DIR(AngleToDir(WrapAngle(EwpnH::getWeapon()->angle)));
30503 EwpnH::getWeapon()->angular = false;
30504 EwpnH::getWeapon()->doAutoRotate(true);
30505 }
30506 }
30507 }
30508
30509 15079 void do_lwpnusesprite(const bool v)
30510 {
30511 15079 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30512
30513
1/2
✓ Branch 0 taken 15079 times.
✗ Branch 1 not taken.
15079 if(BC::checkWeaponMiscSprite(ID, "lweapon->UseSprite") != SH::_NoError)
30514 return;
30515
30516
1/2
✓ Branch 0 taken 15079 times.
✗ Branch 1 not taken.
15079 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->UseSprite") == SH::_NoError)
30517 15079 LwpnH::getWeapon()->LOADGFX(ID);
30518 15079 }
30519
30520 132144 void do_ewpnusesprite(const bool v)
30521 {
30522 132144 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30523
30524
1/2
✓ Branch 0 taken 132144 times.
✗ Branch 1 not taken.
132144 if(BC::checkWeaponMiscSprite(ID, "eweapon->UseSprite") != SH::_NoError)
30525 return;
30526
30527
1/2
✓ Branch 0 taken 132144 times.
✗ Branch 1 not taken.
132144 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->UseSprite") == SH::_NoError)
30528 132144 EwpnH::getWeapon()->LOADGFX(ID);
30529 132144 }
30530
30531 void do_portalusesprite()
30532 {
30533 int32_t ID = get_register(sarg1) / 10000;
30534
30535 if(BC::checkWeaponMiscSprite(ID, "portal->UseSprite") != SH::_NoError)
30536 return;
30537
30538 if(portal* p = checkPortal(ri->portalref, "UseSprite()"))
30539 p->LOADGFX(ID);
30540 }
30541
30542 void do_clearsprites(const bool v)
30543 {
30544 int32_t spritelist = SH::get_arg(sarg1, v) / 10000;
30545
30546 if(BC::checkBounds(spritelist, 0, 5, "Screen->ClearSprites") != SH::_NoError)
30547 return;
30548
30549 switch(spritelist)
30550 {
30551 case 0:
30552 guys.clear();
30553 break;
30554
30555 case 1:
30556 items.clear();
30557 break;
30558
30559 case 2:
30560 Ewpns.clear();
30561 break;
30562
30563 case 3:
30564 Lwpns.clear();
30565 Hero.reset_hookshot();
30566 break;
30567
30568 case 4:
30569 decorations.clear();
30570 break;
30571
30572 case 5:
30573 particles.clear();
30574 break;
30575 }
30576 }
30577
30578 1201098 void do_loadlweapon(const bool v)
30579 {
30580 1201098 int32_t index = SH::get_arg(sarg1, v) / 10000;
30581
30582
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 1187342 times.
1201098 if(BC::checkLWeaponIndex(index, "Screen->LoadLWeapon") != SH::_NoError)
30583 13756 ri->lwpn = 0; //MAX_DWORD; //Now NULL
30584 else
30585 {
30586 1187342 ri->lwpn = Lwpns.spr(index)->getUID();
30587 // This is too trivial to log. -L
30588 //Z_eventlog("Script loaded lweapon with UID = %ld\n", ri->lwpn);
30589 }
30590 1201098 }
30591
30592 2753647 void do_loadeweapon(const bool v)
30593 {
30594 2753647 int32_t index = SH::get_arg(sarg1, v) / 10000;
30595
30596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2753647 times.
2753647 if(BC::checkEWeaponIndex(index, "Screen->LoadEWeapon") != SH::_NoError)
30597 ri->ewpn = 0; //MAX_DWORD; //Now NULL
30598 else
30599 {
30600 2753647 ri->ewpn = Ewpns.spr(index)->getUID();
30601 //Z_eventlog("Script loaded eweapon with UID = %ld\n", ri->ewpn);
30602 }
30603 2753647 }
30604
30605 136832 void do_loaditem(const bool v)
30606 {
30607 136832 int32_t index = SH::get_arg(sarg1, v) / 10000;
30608
30609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136832 times.
136832 if(BC::checkItemIndex(index, "Screen->LoadItem") != SH::_NoError)
30610 ri->itemref = 0; //MAX_DWORD; //Now NULL
30611 else
30612 {
30613 136832 ri->itemref = items.spr(index)->getUID();
30614 //Z_eventlog("Script loaded item with UID = %ld\n", ri->itemref);
30615 }
30616 136832 }
30617
30618
30619 55814 void do_loaditemdata(const bool v)
30620 {
30621 55814 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30622
30623 //I *think* this is the right check ~Joe
30624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55814 times.
55814 if(BC::checkItemID(ID, "Game->LoadItemData") != SH::_NoError)
30625 {
30626 ri->idata = -1; //new null value
30627 return;
30628 }
30629 55814 ri->idata = ID;
30630 //Z_eventlog("Script loaded itemdata with ID = %ld\n", ri->idata);
30631 55814 }
30632
30633 15644354 void do_loadnpc(const bool v)
30634 {
30635 15644354 int32_t index = SH::get_arg(sarg1, v) / 10000;
30636
30637
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 15644273 times.
15644354 if(BC::checkGuyIndex(index, "Screen->LoadNPC") != SH::_NoError)
30638 81 ri->guyref = 0; // MAX_DWORD;
30639 else
30640 {
30641 15644273 ri->guyref = guys.spr(index)->getUID();
30642 //Z_eventlog("Script loaded NPC with UID = %ld\n", ri->guyref);
30643 }
30644 15644354 }
30645
30646 756866 void FFScript::do_loaddmapdata(const bool v)
30647 {
30648 756866 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30649
30650
2/4
✓ Branch 0 taken 756866 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 756866 times.
756866 if ( ID < 0 || ID > 511 )
30651 {
30652 Z_scripterrlog("Invalid DMap ID passed to Game->LoadDMapData(): %d\n", ID);
30653 ri->dmapsref = MAX_DWORD;
30654 }
30655 756866 else ri->dmapsref = ID;
30656 756866 }
30657
30658 void FFScript::do_load_active_subscreendata(const bool v)
30659 {
30660 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30661
30662 if(ID == -1 || (unsigned(ID) < subscreens_active.size() && unsigned(ID) < 256))
30663 {
30664 ri->subdataref = get_subref(ID, sstACTIVE);
30665 }
30666 else
30667 {
30668 Z_scripterrlog("Invalid Subscreen ID passed to Game->LoadASubData(): %d\n", ID);
30669 ri->subdataref = 0;
30670 }
30671 ri->d[rEXP1] = ri->subdataref;
30672 }
30673 void FFScript::do_load_passive_subscreendata(const bool v)
30674 {
30675 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30676
30677 if(ID == -1 || (unsigned(ID) < subscreens_passive.size() && unsigned(ID) < 256))
30678 {
30679 ri->subdataref = get_subref(ID, sstPASSIVE);
30680 }
30681 else
30682 {
30683 Z_scripterrlog("Invalid Subscreen ID passed to Game->LoadPSubData(): %d\n", ID);
30684 ri->subdataref = 0;
30685 }
30686 ri->d[rEXP1] = ri->subdataref;
30687 }
30688 void FFScript::do_load_overlay_subscreendata(const bool v)
30689 {
30690 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30691
30692 if(ID == -1 || (unsigned(ID) < subscreens_overlay.size() && unsigned(ID) < 256))
30693 {
30694 ri->subdataref = get_subref(ID, sstOVERLAY);
30695 }
30696 else
30697 {
30698 Z_scripterrlog("Invalid Subscreen ID passed to Game->LoadOSubData(): %d\n", ID);
30699 ri->subdataref = 0;
30700 }
30701 ri->d[rEXP1] = ri->subdataref;
30702 }
30703 void FFScript::do_load_subscreendata(const bool v, const bool v2)
30704 {
30705 int32_t ty = SH::get_arg(sarg2, v2) / 10000;
30706 switch(ty)
30707 {
30708 case sstACTIVE:
30709 do_load_active_subscreendata(v);
30710 break;
30711 case sstPASSIVE:
30712 do_load_passive_subscreendata(v);
30713 break;
30714 case sstOVERLAY:
30715 do_load_overlay_subscreendata(v);
30716 break;
30717 default:
30718 {
30719 Z_scripterrlog("Invalid Subscreen Type passed to ???: %d\n", ty);
30720 ri->subdataref = 0;
30721 break;
30722 }
30723 }
30724 ri->d[rEXP1] = ri->subdataref;
30725 }
30726
30727 22 void FFScript::do_loadrng()
30728 {
30729 22 ri->rngref = get_free_rng();
30730 22 ri->d[rEXP1] = ri->rngref;
30731 22 }
30732
30733 void FFScript::do_loaddirectory()
30734 {
30735 int32_t arrayptr = get_register(sarg1) / 10000;
30736 string path;
30737 ArrayH::getString(arrayptr, path, 2048);
30738
30739 if(path.find("../") != string::npos
30740 || path.find("..\\") != string::npos)
30741 {
30742 Z_scripterrlog("Error: Script attempted to go up a directory in directory load '%s'\n", path.c_str());
30743 return;
30744 }
30745
30746 size_t pos = path.find_last_not_of("/\\");
30747 if(pos != string::npos && !(path.find_last_of("/\\") < pos))
30748 path = path.substr(0, pos+1);
30749 char buf[2048+1] = {0};
30750 get_scriptfile_path(buf, path.c_str());
30751 regulate_path(buf);
30752 if(valid_dir(buf) && checkPath(buf, true))
30753 {
30754 ri->directoryref = get_free_directory(false);
30755 if(!ri->directoryref) return;
30756 user_dir* d = checkDir(ri->directoryref, "LoadDirectory", true);
30757 set_register(sarg1, ri->directoryref);
30758 d->setPath(buf);
30759 return;
30760 }
30761 Z_scripterrlog("Path '%s' empty or points to a file; must point to a directory!\n",path.c_str());
30762 ri->directoryref = 0;
30763 set_register(sarg1, 0);
30764 }
30765
30766 void FFScript::do_loadstack()
30767 {
30768 ri->stackref = get_free_stack();
30769 ri->d[rEXP1] = ri->stackref;
30770 }
30771
30772 void FFScript::do_loaddropset(const bool v)
30773 {
30774 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30775
30776 if ( ID < 0 || ID > MAXITEMDROPSETS )
30777 {
30778 Z_scripterrlog("Invalid Dropset ID passed to Game->LoadDropset(): %d\n", ID);
30779 ri->dropsetref = MAX_DWORD;
30780 }
30781
30782 else ri->dropsetref = ID;
30783 }
30784
30785 void FFScript::do_loadbottle(const bool v)
30786 {
30787 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30788
30789 if ( ID < 1 || ID > 64 )
30790 {
30791 Z_scripterrlog("Invalid BottleType ID passed to Game->LoadBottleData(): %d\n", ID);
30792 ri->bottletyperef = 0;
30793 }
30794 else ri->bottletyperef = ID;
30795 }
30796
30797 void FFScript::do_loadbottleshop(const bool v)
30798 {
30799 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30800
30801 if ( ID < 0 || ID > 255 )
30802 {
30803 Z_scripterrlog("Invalid BottleShopType ID passed to Game->LoadBottleShopData(): %d\n", ID);
30804 ri->bottleshopref = 0;
30805 }
30806 else ri->bottleshopref = ID+1;
30807 }
30808 68 void FFScript::do_loadgenericdata(const bool v)
30809 {
30810 68 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30811
30812
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
68 if ( ID < 1 || ID > NUMSCRIPTSGENERIC )
30813 {
30814 Z_scripterrlog("Invalid GenericData ID passed to Game->LoadGenericData(): %d\n", ID);
30815 ri->genericdataref = 0;
30816 }
30817 68 else ri->genericdataref = ID;
30818 68 }
30819
30820 void FFScript::do_create_paldata()
30821 {
30822 ri->paldataref = get_free_paldata();
30823 user_paldata* pd = &script_paldatas[ri->paldataref-1];
30824 for (int32_t q = 0; q < PALDATA_BITSTREAM_SIZE; ++q)
30825 pd->colors_used[q] = 0;
30826 ri->d[rEXP1] = ri->paldataref;
30827 }
30828
30829 void FFScript::do_create_paldata_clr()
30830 {
30831 ri->paldataref = get_free_paldata();
30832 user_paldata* pd = &script_paldatas[ri->paldataref - 1];
30833 int32_t clri = get_register(sarg1);
30834
30835 RGB c = _RGB((clri >> 16) & 0xFF, (clri >> 8) & 0xFF, clri & 0xFF);
30836
30837 if (c.r < 0 || c.g < 0 || c.b < 0)
30838 {
30839 Z_scripterrlog("Invalid rgb (%d) passed to Graphics->CreatePalData().\n", clri);
30840 }
30841 c.r = vbound(c.r, 0, 63);
30842 c.g = vbound(c.g, 0, 63);
30843 c.b = vbound(c.b, 0, 63);
30844
30845 for(int32_t q = 0; q < 240; ++q)
30846 pd->set_color(q, c);
30847 ri->d[rEXP1] = ri->paldataref;
30848 }
30849
30850 void FFScript::do_mix_clr()
30851 {
30852 int32_t clr_start = SH::read_stack(ri->sp + 3);
30853 int32_t clr_end = SH::read_stack(ri->sp + 2);
30854 float percent = SH::read_stack(ri->sp + 1) / 10000.0;
30855 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
30856
30857 RGB ref1c = _RGB((clr_start >> 16) & 0xFF, (clr_start >> 8) & 0xFF, clr_start & 0xFF);
30858 RGB ref2c = _RGB((clr_end >> 16) & 0xFF, (clr_end >> 8) & 0xFF, clr_end & 0xFF);
30859 RGB outputc = user_paldata::mix_color(ref1c, ref2c, percent, color_space);
30860
30861 int32_t r = vbound(outputc.r, 0, 63);
30862 int32_t g = vbound(outputc.g, 0, 63);
30863 int32_t b = vbound(outputc.b, 0, 63);
30864
30865 ri->d[rEXP1] = (r << 16) | (g << 8) | b;
30866 }
30867
30868 void FFScript::do_create_rgb_hex()
30869 {
30870 int32_t hexrgb = get_register(sarg1);
30871
30872 int32_t r = (hexrgb >> 16) & 0xFF;
30873 int32_t g = (hexrgb >> 8) & 0xFF;
30874 int32_t b = hexrgb & 0xFF;
30875
30876 //Convert rgb from 8-bit to 6-bit
30877 r = vbound(r / 4, 0, 63);
30878 g = vbound(g / 4, 0, 63);
30879 b = vbound(b / 4, 0, 63);
30880
30881 ri->d[rEXP1] = (r << 16) | (g << 8) | b;
30882 }
30883
30884 void FFScript::do_create_rgb()
30885 {
30886 int32_t r = SH::read_stack(ri->sp + 2) / 10000;
30887 int32_t g = SH::read_stack(ri->sp + 1) / 10000;
30888 int32_t b = SH::read_stack(ri->sp + 0) / 10000;
30889
30890 if (unsigned(r) > 63 || unsigned(g) > 63 || unsigned(b) > 63)
30891 {
30892 Z_scripterrlog("R/G/B values passed to Graphics->CreateRGB() should range from 0-63.\n");
30893 }
30894 r = vbound(r, 0, 63);
30895 g = vbound(g, 0, 63);
30896 b = vbound(b, 0, 63);
30897
30898 ri->d[rEXP1] = (r << 16) | (g << 8) | b;
30899 }
30900
30901 void FFScript::do_convert_from_rgb()
30902 {
30903 int32_t buf = SH::read_stack(ri->sp + 2) / 10000;
30904 int32_t clri = SH::read_stack(ri->sp + 1);
30905 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
30906
30907 ArrayManager am(buf);
30908 if (am.invalid()) return;
30909 int32_t zscript_array_size = am.size();
30910 int32_t target_size;
30911
30912 switch (color_space)
30913 {
30914 case user_paldata::CSPACE_CMYK:
30915 target_size = 4;
30916 break;
30917 default:
30918 target_size = 3;
30919 }
30920
30921 if (zscript_array_size < target_size)
30922 {
30923 Z_scripterrlog("Array supplied to 'Graphics->ConvertFromRGB' not large enough. Should be at least size %d\n", target_size);
30924 return;
30925 }
30926
30927 RGB c = _RGB((clri >> 16) & 0xFF, (clri >> 8) & 0xFF, clri & 0xFF);
30928 double convert[4];
30929 user_paldata::RGBTo(c, convert, color_space);
30930
30931 for (int32_t q = 0; q < target_size; ++q)
30932 {
30933 am.set(q, int32_t(convert[q]*10000));
30934 }
30935
30936 return;
30937 }
30938
30939 void FFScript::do_convert_to_rgb()
30940 {
30941 int32_t buf = SH::read_stack(ri->sp + 1) / 10000;
30942 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
30943
30944 ArrayManager am(buf);
30945 if (am.invalid()) return;
30946 int32_t zscript_array_size = am.size();
30947 int32_t target_size;
30948
30949 switch (color_space)
30950 {
30951 case user_paldata::CSPACE_CMYK:
30952 target_size = 4;
30953 break;
30954 default:
30955 target_size = 3;
30956 }
30957
30958 if (zscript_array_size < target_size)
30959 {
30960 Z_scripterrlog("Array supplied to 'Graphics->ConvertToRGB' not large enough. Should be at least size %d\n", target_size);
30961 return;
30962 }
30963
30964 double convert[4];
30965 for (int32_t q = 0; q < target_size; ++q)
30966 {
30967 convert[q] = am.get(q) / 10000.0;
30968 }
30969 RGB c = user_paldata::RGBFrom(convert, color_space);
30970
30971 ri->d[rEXP1] = (c.r << 16) | (c.g << 8) | c.b;
30972 }
30973
30974 void FFScript::do_paldata_load_level()
30975 {
30976 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadLevelPalette()"))
30977 {
30978 int32_t lvl = get_register(sarg1) / 10000;
30979 //Load CSets 2-4
30980 pd->load_cset(2, lvl * pdLEVEL + poLEVEL + 0);
30981 pd->load_cset(3, lvl * pdLEVEL + poLEVEL + 1);
30982 pd->load_cset(4, lvl * pdLEVEL + poLEVEL + 2);
30983 //Load CSet 9
30984 pd->load_cset(9, lvl * pdLEVEL + poLEVEL + 3);
30985 //Load 1, 5, 7, 8
30986 pd->load_cset(1, lvl * pdLEVEL + poNEWCSETS);
30987 pd->load_cset(5, lvl * pdLEVEL + poNEWCSETS + 1);
30988 pd->load_cset(7, lvl * pdLEVEL + poNEWCSETS + 2);
30989 pd->load_cset(8, lvl * pdLEVEL + poNEWCSETS + 3);
30990 }
30991 return;
30992 }
30993
30994 void FFScript::do_paldata_load_sprite()
30995 {
30996 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadSpritePalette()"))
30997 {
30998 int32_t page = get_register(sarg1) / 10000;
30999
31000 int32_t pageoffset = 0;
31001 switch (page)
31002 {
31003 case 0: pageoffset += 0; break;
31004 case 1: pageoffset += 15; break;
31005 default:
31006 Z_scripterrlog("Invalid page (%d) passed to paldata->LoadSpritePalette(). Valid pages are 0 or 1. Aborting.\n", page);
31007 return;
31008 }
31009 for (int32_t q = 0; q < 15; ++q)
31010 {
31011 pd->load_cset(q, poSPRITE255 + pageoffset + q);
31012 }
31013 }
31014 return;
31015 }
31016
31017 void FFScript::do_paldata_load_main()
31018 {
31019 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadMainPalette()"))
31020 {
31021 for (int32_t q = 0; q <= 15; ++q)
31022 {
31023 pd->load_cset_main(q);
31024 }
31025 }
31026 return;
31027 }
31028
31029 void FFScript::do_paldata_load_cycle()
31030 {
31031 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadCyclePalette()"))
31032 {
31033 int32_t lvl = get_register(sarg1) / 10000;
31034 for (int32_t q = 4; q <= 12; ++q)
31035 {
31036 pd->load_cset(q, lvl * pdLEVEL + poLEVEL + q);
31037 }
31038 }
31039 return;
31040 }
31041
31042 void FFScript::do_paldata_load_bitmap()
31043 {
31044 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadBitmapPalette()"))
31045 {
31046 int32_t pathptr = get_register(sarg1) / 10000;
31047 string str;
31048 ArrayH::getString(pathptr, str, 256);
31049
31050 if (get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE))
31051 {
31052 char buf[2048+1] = { 0 };
31053 if (FFCore.get_scriptfile_path(buf, str.c_str()))
31054 str = buf;
31055 }
31056 regulate_path(str);
31057
31058 if (str.empty())
31059 {
31060 al_trace("String pointer is null! Internal error. \n");
31061 return;
31062 }
31063
31064 PALETTE tempPal;
31065 get_palette(tempPal);
31066 if (checkPath(str.c_str(), false))
31067 {
31068 BITMAP* bmp = load_bitmap(str.c_str(), tempPal);
31069 if (!bmp)
31070 {
31071 Z_scripterrlog("LoadBitmapPalette() failed to load image file %s.\n", str.c_str());
31072 }
31073 else
31074 {
31075 for (int32_t q = 0; q < PALDATA_NUM_COLORS; ++q)
31076 {
31077 pd->colors[q] = tempPal[q];
31078 set_bit(pd->colors_used, q, true);
31079 }
31080 }
31081 destroy_bitmap(bmp);
31082 }
31083 else
31084 {
31085 Z_scripterrlog("Failed to load image file: %s. File not found.\n", str.c_str());
31086 }
31087 }
31088 return;
31089 }
31090
31091 void FFScript::do_paldata_write_level()
31092 {
31093 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteLevelPalette()"))
31094 {
31095 int32_t lvl = get_register(sarg1) / 10000;
31096 bool changed = false;
31097 //Write CSets 2-4
31098 if (pd->check_cset(2, lvl * pdLEVEL + poLEVEL + 0))
31099 {
31100 pd->write_cset(2, lvl * pdLEVEL + poLEVEL + 0);
31101 changed = true;
31102 }
31103 if (pd->check_cset(3, lvl * pdLEVEL + poLEVEL + 1))
31104 {
31105 pd->write_cset(3, lvl * pdLEVEL + poLEVEL + 1);
31106 changed = true;
31107 }
31108 if (pd->check_cset(4, lvl * pdLEVEL + poLEVEL + 2))
31109 {
31110 pd->write_cset(4, lvl * pdLEVEL + poLEVEL + 2);
31111 changed = true;
31112 }
31113 //Write CSet 9
31114 if (pd->check_cset(9, lvl * pdLEVEL + poLEVEL + 3))
31115 {
31116 pd->write_cset(9, lvl * pdLEVEL + poLEVEL + 3);
31117 changed = true;
31118 }
31119 //Write 1, 5, 7, 8
31120 if (pd->check_cset(1, lvl * pdLEVEL + poNEWCSETS + 0))
31121 {
31122 pd->write_cset(1, lvl * pdLEVEL + poNEWCSETS + 0);
31123 changed = true;
31124 }
31125 if (pd->check_cset(5, lvl * pdLEVEL + poNEWCSETS + 1))
31126 {
31127 pd->write_cset(5, lvl * pdLEVEL + poNEWCSETS + 1);
31128 changed = true;
31129 }
31130 if (pd->check_cset(7, lvl * pdLEVEL + poNEWCSETS + 2))
31131 {
31132 pd->write_cset(7, lvl * pdLEVEL + poNEWCSETS + 2);
31133 changed = true;
31134 }
31135 if (pd->check_cset(8, lvl * pdLEVEL + poNEWCSETS + 3))
31136 {
31137 pd->write_cset(8, lvl * pdLEVEL + poNEWCSETS + 3);
31138 changed = true;
31139 }
31140
31141 if (changed && DMaps[currdmap].color == lvl)
31142 {
31143 loadlvlpal(lvl);
31144 currcset = lvl;
31145 if (darkroom && !get_qr(qr_NEW_DARKROOM))
31146 {
31147 if (get_qr(qr_FADE))
31148 {
31149 interpolatedfade();
31150 }
31151 else
31152 {
31153 loadfadepal((DMaps[currdmap].color) * pdLEVEL + poFADE3);
31154 }
31155 }
31156 }
31157 }
31158 return;
31159 }
31160
31161 void FFScript::do_paldata_write_levelcset()
31162 {
31163 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteLevelCSet()"))
31164 {
31165 int32_t lvl = get_register(sarg1) / 10000;
31166 int32_t cs = get_register(sarg2) / 10000;
31167
31168 bool changed = false;
31169
31170 switch (cs)
31171 {
31172 case 1:
31173 if (pd->check_cset(1, lvl * pdLEVEL + poNEWCSETS + 0))
31174 {
31175 pd->write_cset(1, lvl * pdLEVEL + poNEWCSETS + 0);
31176 changed = true;
31177 }
31178 break;
31179 case 2:
31180 if (pd->check_cset(2, lvl * pdLEVEL + poLEVEL + 0))
31181 {
31182 pd->write_cset(2, lvl * pdLEVEL + poLEVEL + 0);
31183 changed = true;
31184 }
31185 break;
31186 case 3:
31187 if (pd->check_cset(3, lvl * pdLEVEL + poLEVEL + 1))
31188 {
31189 pd->write_cset(3, lvl * pdLEVEL + poLEVEL + 1);
31190 changed = true;
31191 }
31192 break;
31193 case 4:
31194 if (pd->check_cset(4, lvl * pdLEVEL + poLEVEL + 2))
31195 {
31196 pd->write_cset(4, lvl * pdLEVEL + poLEVEL + 2);
31197 changed = true;
31198 }
31199 break;
31200 case 5:
31201 if (pd->check_cset(5, lvl * pdLEVEL + poNEWCSETS + 1))
31202 {
31203 pd->write_cset(5, lvl * pdLEVEL + poNEWCSETS + 1);
31204 changed = true;
31205 }
31206 break;
31207 case 7:
31208 if (pd->check_cset(7, lvl * pdLEVEL + poNEWCSETS + 2))
31209 {
31210 pd->write_cset(7, lvl * pdLEVEL + poNEWCSETS + 2);
31211 changed = true;
31212 }
31213 break;
31214 case 8:
31215 if (pd->check_cset(8, lvl * pdLEVEL + poNEWCSETS + 3))
31216 {
31217 pd->write_cset(8, lvl * pdLEVEL + poNEWCSETS + 3);
31218 changed = true;
31219 }
31220 break;
31221 case 9:
31222 if (pd->check_cset(9, lvl * pdLEVEL + poLEVEL + 3))
31223 {
31224 pd->write_cset(9, lvl * pdLEVEL + poLEVEL + 3);
31225 changed = true;
31226 }
31227 break;
31228 default:
31229 Z_scripterrlog("Invalid CSet (%d) passed to 'paldata->WriteLevelCSet()'. Level palettes can use CSets 1, 2, 3, 4, 5, 7, 8, 9.\n");
31230 return;
31231 }
31232
31233 if (changed && DMaps[currdmap].color == lvl)
31234 {
31235 loadlvlpal(lvl);
31236 if (darkroom && !get_qr(qr_NEW_DARKROOM))
31237 {
31238 if (get_qr(qr_FADE))
31239 {
31240 interpolatedfade();
31241 }
31242 else
31243 {
31244 loadfadepal((DMaps[currdmap].color) * pdLEVEL + poFADE3);
31245 }
31246 }
31247 currcset = lvl;
31248 }
31249 }
31250 }
31251
31252 void FFScript::do_paldata_write_sprite()
31253 {
31254 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteSpritePalette()"))
31255 {
31256 int32_t page = get_register(sarg1) / 10000;
31257
31258 int32_t pageoffset = 0;
31259 switch (page)
31260 {
31261 case 0: pageoffset += 0; break;
31262 case 1: pageoffset += 15; break;
31263 default:
31264 Z_scripterrlog("Invalid page (%d) passed to paldata->WriteSpritePalette(). Valid pages are 0 or 1. Aborting.\n", page);
31265 return;
31266 }
31267 bool changed6 = false;
31268 bool changed14 = false;
31269 for (int32_t q = 0; q < 15; ++q)
31270 {
31271 if (pd->check_cset(q, poSPRITE255 + pageoffset + q))
31272 {
31273 pd->write_cset(q, poSPRITE255 + pageoffset + q);
31274 if (pageoffset + q == currspal6)
31275 {
31276 changed6 = true;
31277 }
31278 if (pageoffset + q == currspal14)
31279 {
31280 changed14 = true;
31281 }
31282 }
31283 }
31284
31285 //If either sprite palette has been changed, update the main palette
31286 if (changed6 || changed14)
31287 {
31288 if (changed6)
31289 {
31290 loadpalset(6, poSPRITE255 + currspal6, false);
31291 }
31292 if (changed14)
31293 {
31294 loadpalset(14, poSPRITE255 + currspal14, false);
31295 }
31296
31297 if (isMonochrome()) {
31298 if (lastMonoPreset) {
31299 restoreMonoPreset();
31300 }
31301 else {
31302 setMonochrome(false);
31303 setMonochrome(true);
31304 }
31305 }
31306
31307 if (isUserTinted()) {
31308 restoreTint();
31309 }
31310 }
31311 }
31312 return;
31313 }
31314
31315 void FFScript::do_paldata_write_spritecset()
31316 {
31317 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteSpritePalette()"))
31318 {
31319 int32_t page = get_register(sarg1) / 10000;
31320 int32_t cs = get_register(sarg2) / 10000;
31321
31322 int32_t pageoffset = 0;
31323 switch (page)
31324 {
31325 case 0: pageoffset += 0; break;
31326 case 1: pageoffset += 15; break;
31327 default:
31328 Z_scripterrlog("Invalid page (%d) passed to paldata->WriteSpriteCSet(). Valid pages are 0 or 1. Aborting.\n", page);
31329 return;
31330 }
31331 bool changed6 = false;
31332 bool changed14 = false;
31333 if (unsigned(cs) > 15)
31334 {
31335 Z_scripterrlog("Invalid CSet (%d) passed to paldata->WriteSpriteCSet(). Valid CSets are 0-15. Aborting.\n", cs);
31336 return;
31337 }
31338 if (pd->check_cset(cs, poSPRITE255 + pageoffset + cs))
31339 {
31340 pd->write_cset(cs, poSPRITE255 + pageoffset + cs);
31341 if (pageoffset + cs == currspal6)
31342 {
31343 changed6 = true;
31344 }
31345 if (pageoffset + cs == currspal14)
31346 {
31347 changed14 = true;
31348 }
31349 }
31350
31351 //If either sprite palette has been changed, update the main palette
31352 if (changed6 || changed14)
31353 {
31354 if (changed6)
31355 {
31356 loadpalset(6, poSPRITE255 + currspal6, false);
31357 }
31358 if (changed14)
31359 {
31360 loadpalset(14, poSPRITE255 + currspal14, false);
31361 }
31362
31363 if (isMonochrome()) {
31364 if (lastMonoPreset) {
31365 restoreMonoPreset();
31366 }
31367 else {
31368 setMonochrome(false);
31369 setMonochrome(true);
31370 }
31371 }
31372
31373 if (isUserTinted()) {
31374 restoreTint();
31375 }
31376 }
31377 }
31378 return;
31379 }
31380
31381 void FFScript::do_paldata_write_main()
31382 {
31383 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteMainPalette()"))
31384 {
31385 bool changed = false;
31386 for (int32_t q = 0; q <= 15; ++q)
31387 {
31388 if (pd->check_cset_main(q))
31389 {
31390 pd->write_cset_main(q);
31391 changed = true;
31392 }
31393 }
31394
31395 if (changed)
31396 {
31397 refreshpal = true;
31398 }
31399 }
31400 return;
31401 }
31402
31403 void FFScript::do_paldata_write_maincset()
31404 {
31405 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteMainCSet()"))
31406 {
31407 int32_t cs = get_register(sarg1) / 10000;
31408
31409 bool changed = false;
31410
31411 if (unsigned(cs) < 16)
31412 {
31413 if (pd->check_cset_main(cs))
31414 {
31415 pd->write_cset_main(cs);
31416 changed = true;
31417 }
31418 }
31419 else
31420 {
31421 Z_scripterrlog("Invalid CSet (%d) passed to 'paldata->WriteMainCSet()'. Valid csets are 0-15. Aborting.\n");
31422 return;
31423 }
31424
31425 if (changed)
31426 {
31427 refreshpal = true;
31428 }
31429 }
31430 }
31431
31432 void FFScript::do_paldata_write_cycle()
31433 {
31434 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteCyclePalette()"))
31435 {
31436 int32_t lvl = get_register(sarg1) / 10000;
31437 for (int32_t q = 4; q <= 12; ++q)
31438 {
31439 if (pd->check_cset(q, lvl * pdLEVEL + poLEVEL + q))
31440 {
31441 pd->write_cset(q, lvl * pdLEVEL + poLEVEL + q);
31442 }
31443 }
31444 }
31445 return;
31446 }
31447
31448 void FFScript::do_paldata_write_cyclecset()
31449 {
31450 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteCycleCSet()"))
31451 {
31452 int32_t lvl = get_register(sarg1) / 10000;
31453 int32_t cs = get_register(sarg2) / 10000;
31454
31455 bool changed = false;
31456
31457 switch (cs)
31458 {
31459 case 4:
31460 case 5:
31461 case 6:
31462 case 7:
31463 case 8:
31464 case 9:
31465 case 10:
31466 case 11:
31467 case 12:
31468 if (pd->check_cset(cs, lvl * pdLEVEL + poLEVEL + cs))
31469 {
31470 pd->write_cset(cs, lvl * pdLEVEL + poLEVEL + cs);
31471 changed = true;
31472 }
31473 break;
31474 default:
31475 Z_scripterrlog("Invalid CSet (%d) passed to 'paldata->WriteCycleCSet()'. Cycle palettes use CSets 4-12.\n");
31476 return;
31477 }
31478
31479 if (changed && DMaps[currdmap].color == lvl)
31480 {
31481 loadlvlpal(lvl);
31482 currcset = lvl;
31483 }
31484 }
31485 }
31486
31487 void FFScript::do_paldata_colorvalid()
31488 {
31489 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->ColorValid()"))
31490 {
31491 int32_t ind = get_register(sarg1) / 10000;
31492 if (unsigned(ind) >= PALDATA_NUM_COLORS)
31493 {
31494 Z_scripterrlog("Invalid color index (%d) passed to paldata->ColorValid(). Valid indices are 0-255.\n", ind);
31495 set_register(sarg1, 0);
31496 return;
31497 }
31498
31499 if (get_bit(pd->colors_used, ind))
31500 {
31501 set_register(sarg1, 10000);
31502 }
31503 else
31504 {
31505 set_register(sarg1, 0);
31506 }
31507 }
31508 }
31509
31510 void FFScript::do_paldata_clearcolor()
31511 {
31512 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->SetColor()"))
31513 {
31514 int32_t ind = get_register(sarg1) / 10000;
31515 if (unsigned(ind) >= PALDATA_NUM_COLORS)
31516 {
31517 Z_scripterrlog("Invalid color index (%d) passed to paldata->ClearColor(). Valid indices are 0-255. Aborting.\n", ind);
31518 return;
31519 }
31520 set_bit(pd->colors_used, ind, false);
31521 }
31522 }
31523
31524 void FFScript::do_paldata_clearcset()
31525 {
31526 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->ClearCSet()"))
31527 {
31528 int32_t cs = get_register(sarg1) / 10000;
31529 if (unsigned(cs) > 15)
31530 {
31531 Z_scripterrlog("Invalid cset (%d) passed to paldata->ClearCSet(). Valid csets are 0-15. Aborting.\n", cs);
31532 return;
31533 }
31534 for (int32_t q = 0; q < 16; ++q)
31535 {
31536 set_bit(pd->colors_used, CSET(cs) + q, false);
31537 }
31538 }
31539 }
31540
31541 int32_t FFScript::do_paldata_getrgb(int32_t v)
31542 {
31543 const char* fname = "";
31544 switch (v)
31545 {
31546 case 0: fname = "paldata->R[]"; break;
31547 case 1: fname = "paldata->G[]"; break;
31548 case 2: fname = "paldata->B[]"; break;
31549 }
31550 if (user_paldata* pd = checkPalData(ri->paldataref, fname))
31551 {
31552 int32_t ind = ri->d[rINDEX] / 10000;
31553 if (unsigned(ind) >= PALDATA_NUM_COLORS)
31554 {
31555 Z_scripterrlog("Invalid color index (%d) passed to %s. Valid indices are 0-255.\n", ind, fname);
31556 return -10000;
31557 }
31558 if (!get_bit(pd->colors_used, ind))
31559 {
31560 Z_scripterrlog("%s tried to access unused color %d.\n", fname, ind);
31561 return -10000;
31562 }
31563 switch (v)
31564 {
31565 case 0:
31566 return pd->colors[ind].r * 10000;
31567 case 1:
31568 return pd->colors[ind].g * 10000;
31569 case 2:
31570 return pd->colors[ind].b * 10000;
31571 }
31572 }
31573 return -10000;
31574 }
31575
31576 void FFScript::do_paldata_setrgb(int32_t v, int32_t val)
31577 {
31578 const char* fname = "";
31579 switch (v)
31580 {
31581 case 0: fname = "paldata->R[]"; break;
31582 case 1: fname = "paldata->G[]"; break;
31583 case 2: fname = "paldata->B[]"; break;
31584 }
31585 if (user_paldata* pd = checkPalData(ri->paldataref, fname))
31586 {
31587 int32_t ind = ri->d[rINDEX] / 10000;
31588 if (unsigned(ind) >= PALDATA_NUM_COLORS)
31589 {
31590 Z_scripterrlog("Invalid color index (%d) passed to %s. Valid indices are 0-255. Aborting.\n", ind, fname);
31591 return;
31592 }
31593 if (unsigned(val) > 63)
31594 {
31595 Z_scripterrlog("RGB value(%d) passed to %s is out of range. RGB values range from 0 - 63.\n", val, fname);
31596 val = vbound(val, 0, 63);
31597 }
31598 if (!get_bit(pd->colors_used, ind))
31599 {
31600 Z_scripterrlog("%s tried to access unused color %d.\n", fname, ind);
31601 return;
31602 }
31603 switch (v)
31604 {
31605 case 0:
31606 pd->colors[ind].r = val;
31607 break;
31608 case 1:
31609 pd->colors[ind].g = val;
31610 break;
31611 case 2:
31612 pd->colors[ind].b = val;
31613 break;
31614 }
31615 }
31616 }
31617
31618 void FFScript::do_paldata_mix()
31619 {
31620 int32_t ref = SH::read_stack(ri->sp + 4);
31621 if (user_paldata* pd = checkPalData(ref, "paldata->Mix()"))
31622 {
31623 int32_t ref1 = SH::read_stack(ri->sp + 3);
31624 int32_t ref2 = SH::read_stack(ri->sp + 2);
31625 double percent = SH::read_stack(ri->sp + 1)/10000.0;
31626 int32_t color_space = SH::read_stack(ri->sp + 0)/10000;
31627 if (user_paldata* pd_start = checkPalData(ref1, "paldata->Mix()"))
31628 {
31629 if (user_paldata* pd_end = checkPalData(ref2, "paldata->Mix()"))
31630 {
31631 pd->mix(pd_start, pd_end, percent, color_space);
31632 }
31633 }
31634 }
31635 }
31636
31637 void FFScript::do_paldata_mixcset()
31638 {
31639 int32_t ref = SH::read_stack(ri->sp + 5);
31640 if (user_paldata* pd = checkPalData(ref, "paldata->MixCSet()"))
31641 {
31642 int32_t ref1 = SH::read_stack(ri->sp + 4);
31643 int32_t ref2 = SH::read_stack(ri->sp + 3);
31644 int32_t cset = SH::read_stack(ri->sp + 2) / 10000;
31645 double percent = SH::read_stack(ri->sp + 1) / 10000.0;
31646 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
31647 if (user_paldata* pd_start = checkPalData(ref1, "paldata->MixCSet()"))
31648 {
31649 if (user_paldata* pd_end = checkPalData(ref2, "paldata->MixCSet()"))
31650 {
31651 if (unsigned(cset) > 15)
31652 {
31653 Z_scripterrlog("CSet passed to 'paldata->MixCSet()' out of range. Valid CSets are 0-15\n");
31654 return;
31655 }
31656 pd->mix(pd_start, pd_end, percent, color_space, CSET(cset), CSET(cset) + 16);
31657 }
31658 }
31659 }
31660 }
31661
31662 void FFScript::do_paldata_copy()
31663 {
31664 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->Copy()"))
31665 {
31666 int32_t ref_dest = get_register(sarg1);
31667 if (user_paldata* pd_dest = checkPalData(ref_dest, "paldata->Copy()"))
31668 {
31669 for (int32_t q = 0; q < PALDATA_NUM_COLORS; ++q)
31670 {
31671 pd_dest->colors[q] = pd->colors[q];
31672 }
31673 for (int32_t q = 0; q < PALDATA_BITSTREAM_SIZE; ++q)
31674 {
31675 pd_dest->colors_used[q] = pd->colors_used[q];
31676 }
31677 }
31678 }
31679 }
31680
31681 void FFScript::do_paldata_copycset()
31682 {
31683 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->CopyCSet()"))
31684 {
31685 int32_t ref_dest = SH::read_stack(ri->sp + 2);
31686 int32_t cs = SH::read_stack(ri->sp + 1) / 10000;
31687 int32_t cs_dest = SH::read_stack(ri->sp + 0) / 10000;
31688 if (user_paldata* pd_dest = checkPalData(ref_dest, "paldata->CopyCSet()"))
31689 {
31690 if (unsigned(cs) > 15)
31691 {
31692 Z_scripterrlog("Invalid CSet (%d) passed to paldata->CopyCSet(). Valid CSets are 0-15. Aborting.\n", cs);
31693 return;
31694 }
31695 for (int32_t q = 0; q < 16; ++q)
31696 {
31697 pd_dest->colors[CSET(cs_dest) + q] = pd->colors[CSET(cs) + q];
31698 set_bit(pd_dest->colors_used, CSET(cs_dest) + q, bool(get_bit(pd->colors_used, CSET(cs) + q)));
31699 }
31700 }
31701 }
31702 }
31703
31704 //Loads a cset to paldata from memory
31705 void user_paldata::load_cset(int32_t cset, int32_t dataset)
31706 {
31707 byte* si = colordata + CSET(dataset) * 3;
31708 for (int32_t q = 0; q < 16; ++q)
31709 {
31710 int32_t ind = CSET(cset) + q;
31711 colors[ind].r = si[0];
31712 colors[ind].g = si[1];
31713 colors[ind].b = si[2];
31714 set_bit(colors_used, ind, true);
31715 si += 3;
31716 }
31717 }
31718
31719 //Loads a cset to paldata from the main palette
31720 void user_paldata::load_cset_main(int32_t cset)
31721 {
31722 for (int32_t q = 0; q < 16; ++q)
31723 {
31724 int32_t ind = CSET(cset) + q;
31725 colors[ind].r = RAMpal[ind].r;
31726 colors[ind].g = RAMpal[ind].g;
31727 colors[ind].b = RAMpal[ind].b;
31728 set_bit(colors_used, ind, true);
31729 }
31730 }
31731
31732 //Writes to a memory cset from paldata
31733 void user_paldata::write_cset(int32_t cset, int32_t dataset)
31734 {
31735 byte* si = colordata + CSET(dataset) * 3;
31736 for (int32_t q = 0; q < 16; ++q)
31737 {
31738 int32_t ind = CSET(cset) + q;
31739 if (get_bit(colors_used, ind))
31740 {
31741 si[0] = colors[ind].r;
31742 si[1] = colors[ind].g;
31743 si[2] = colors[ind].b;
31744 }
31745 si += 3;
31746 }
31747 }
31748
31749 //Writes to a main palette cset from paldata
31750 void user_paldata::write_cset_main(int32_t cset)
31751 {
31752 for (int32_t q = 0; q < 16; ++q)
31753 {
31754 int32_t ind = CSET(cset) + q;
31755 if (get_bit(colors_used, ind))
31756 {
31757 RAMpal[ind] = colors[ind];
31758 }
31759 }
31760 }
31761
31762
31763 //Checks a memory cset from
31764
31765
31766
31767
31768 bool user_paldata::check_cset(int32_t cset, int32_t dataset)
31769 {
31770 byte* si = colordata + CSET(dataset) * 3;
31771 for (int32_t q = 0; q < 16; ++q)
31772 {
31773 int32_t ind = CSET(cset) + q;
31774 if (get_bit(colors_used, ind))
31775 {
31776 if (si[0] != colors[ind].r)
31777 return true;
31778 if (si[1] != colors[ind].g)
31779 return true;
31780 if (si[2] != colors[ind].b)
31781 return true;
31782 }
31783 si += 3;
31784 }
31785 return false;
31786 }
31787
31788 //Checks a memory cset from the main palette
31789 bool user_paldata::check_cset_main(int32_t cset)
31790 {
31791 for (int32_t q = 0; q < 16; ++q)
31792 {
31793 int32_t ind = CSET(cset) + q;
31794 if (get_bit(colors_used, ind))
31795 {
31796 if (RAMpal[ind].r != colors[ind].r)
31797 return true;
31798 if (RAMpal[ind].g != colors[ind].g)
31799 return true;
31800 if (RAMpal[ind].b != colors[ind].b)
31801 return true;
31802 }
31803 }
31804 return false;
31805 }
31806
31807 //Mixes a color between two paldatas
31808 RGB user_paldata::mix_color(RGB start, RGB end, double percent, int32_t color_space)
31809 {
31810 int32_t direction = 0;
31811 switch (color_space)
31812 {
31813 case CSPACE_RGB:
31814 return _RGB(byte(vbound(double(zc::math::Lerp(start.r, end.r, percent)), 0.0, 63.0)),
31815 byte(vbound(double(zc::math::Lerp(start.g, end.g, percent)), 0.0, 63.0)),
31816 byte(vbound(double(zc::math::Lerp(start.b, end.b, percent)), 0.0, 63.0)));
31817 case CSPACE_CMYK:
31818 {
31819 double convert_start[4];
31820 double convert_end[4];
31821 double convert_result[4];
31822 RGBTo(start, convert_start, color_space);
31823 RGBTo(end, convert_end, color_space);
31824 convert_result[0] = zc::math::Lerp(convert_start[0], convert_end[0], percent);
31825 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
31826 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
31827 convert_result[3] = zc::math::Lerp(convert_start[3], convert_end[3], percent);
31828 return RGBFrom(convert_result, color_space);
31829 }
31830 case CSPACE_HSV_CW:
31831 if (color_space == CSPACE_HSV_CW)
31832 direction = 1;
31833 [[fallthrough]];
31834 case CSPACE_HSV_CCW:
31835 if (color_space == CSPACE_HSV_CCW)
31836 direction = -1;
31837 [[fallthrough]];
31838 case CSPACE_HSV:
31839 {
31840 double convert_start[3];
31841 double convert_end[3];
31842 double convert_result[3];
31843 RGBTo(start, convert_start, color_space);
31844 RGBTo(end, convert_end, color_space);
31845 convert_result[0] = WrapLerp(convert_start[0], convert_end[0], percent, 0.0, 1.0, direction);
31846 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
31847 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
31848 return RGBFrom(convert_result, color_space);
31849 }
31850 case CSPACE_HSL_CW:
31851 if (color_space == CSPACE_HSL_CW)
31852 direction = 1;
31853 [[fallthrough]];
31854 case CSPACE_HSL_CCW:
31855 if (color_space == CSPACE_HSL_CCW)
31856 direction = -1;
31857 [[fallthrough]];
31858 case CSPACE_HSL:
31859 {
31860 double convert_start[3];
31861 double convert_end[3];
31862 double convert_result[3];
31863 RGBTo(start, convert_start, color_space);
31864 RGBTo(end, convert_end, color_space);
31865 convert_result[0] = WrapLerp(convert_start[0], convert_end[0], percent, 0.0, 1.0, direction);
31866 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
31867 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
31868 return RGBFrom(convert_result, color_space);
31869 }
31870 case CSPACE_LAB:
31871 {
31872 double convert_start[3];
31873 double convert_end[3];
31874 double convert_result[3];
31875 RGBTo(start, convert_start, color_space);
31876 RGBTo(end, convert_end, color_space);
31877 convert_result[0] = zc::math::Lerp(convert_start[0], convert_end[0], percent);
31878 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
31879 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
31880 return RGBFrom(convert_result, color_space);
31881 }
31882 case CSPACE_LCH_CW:
31883 if (color_space == CSPACE_LCH_CW)
31884 direction = 1;
31885 [[fallthrough]];
31886 case CSPACE_LCH_CCW:
31887 if (color_space == CSPACE_LCH_CCW)
31888 direction = -1;
31889 [[fallthrough]];
31890 case CSPACE_LCH:
31891 {
31892 double convert_start[3];
31893 double convert_end[3];
31894 double convert_result[3];
31895 RGBTo(start, convert_start, color_space);
31896 RGBTo(end, convert_end, color_space);
31897 convert_result[0] = zc::math::Lerp(convert_start[0], convert_end[0], percent);
31898 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
31899 convert_result[2] = WrapLerp(convert_start[2], convert_end[2], percent, 0.0, 360.0, direction);
31900 return RGBFrom(convert_result, color_space);
31901 }
31902 }
31903 return start;
31904 }
31905
31906 void user_paldata::RGBTo(RGB c, double arr[], int32_t color_space)
31907 {
31908 //From easyrgb.com/en/math.php
31909 double r = vbound(c.r / 63.0, 0.0, 1.0);
31910 double g = vbound(c.g / 63.0, 0.0, 1.0);
31911 double b = vbound(c.b / 63.0, 0.0, 1.0);
31912 switch (color_space)
31913 {
31914 case CSPACE_CMYK:
31915 {
31916 double c = 1.0 - r;
31917 double m = 1.0 - g;
31918 double y = 1.0 - b;
31919
31920 double k = 1.0;
31921
31922 if (c < k) k = c;
31923 if (m < k) k = m;
31924 if (y < k) k = y;
31925 if (k == 1)
31926 {
31927 c = 0.0;
31928 m = 0.0;
31929 y = 0.0;
31930 }
31931 else
31932 {
31933 c = (c - k) / (1.0 - k);
31934 m = (m - k) / (1.0 - k);
31935 y = (y - k) / (1.0 - k);
31936 }
31937 arr[0] = c;
31938 arr[1] = m;
31939 arr[2] = y;
31940 arr[3] = k;
31941 break;
31942 }
31943 case CSPACE_HSV_CW:
31944 case CSPACE_HSV_CCW:
31945 case CSPACE_HSV:
31946 {
31947 double min_val = std::min(std::min(r, g), b);
31948 double max_val = std::max(std::max(r, g), b);
31949 double del_max = max_val - min_val;
31950
31951 double h = 0;
31952 double s = 0;
31953 double v = max_val;
31954
31955 if (del_max != 0) //Set chroma if not gray
31956 {
31957 s = del_max / max_val;
31958
31959 double del_r = (((max_val - r) / 6.0) + (del_max / 2.0)) / del_max;
31960 double del_g = (((max_val - g) / 6.0) + (del_max / 2.0)) / del_max;
31961 double del_b = (((max_val - b) / 6.0) + (del_max / 2.0)) / del_max;
31962
31963 if (r == max_val) h = del_b - del_g;
31964 else if (g == max_val) h = (1.0 / 3.0) + del_r - del_b;
31965 else if (b == max_val) h = (2.0 / 3.0) + del_g - del_r;
31966
31967 if (h < 0) ++h;
31968 if (h > 1) --h;
31969 }
31970
31971 arr[0] = h;
31972 arr[1] = s;
31973 arr[2] = v;
31974 break;
31975 }
31976 case CSPACE_HSL_CW:
31977 case CSPACE_HSL_CCW:
31978 case CSPACE_HSL:
31979 {
31980 double min_val = std::min(std::min(r, g), b);
31981 double max_val = std::max(std::max(r, g), b);
31982 double del_max = max_val - min_val;
31983
31984 double h = 0;
31985 double s = 0;
31986 double l = (max_val + min_val) / 2.0;
31987
31988 if (del_max != 0) //Set chroma if not gray
31989 {
31990 if (l < 0.5) s = del_max / (max_val + min_val);
31991 else s = del_max / (2 - max_val - min_val);
31992
31993 double del_r = (((max_val - r) / 6.0) + (del_max / 2.0)) / del_max;
31994 double del_g = (((max_val - g) / 6.0) + (del_max / 2.0)) / del_max;
31995 double del_b = (((max_val - b) / 6.0) + (del_max / 2.0)) / del_max;
31996
31997 if (r == max_val) h = del_b - del_g;
31998 else if (g == max_val) h = (1.0 / 3.0) + del_r - del_b;
31999 else if (b == max_val) h = (2.0 / 3.0) + del_g - del_r;
32000
32001 if (h < 0) ++h;
32002 if (h > 1) --h;
32003 }
32004
32005 arr[0] = h;
32006 arr[1] = s;
32007 arr[2] = l;
32008 break;
32009 }
32010 case CSPACE_LAB:
32011 {
32012 if (r > 0.04045) r = pow(((r + 0.055) / 1.055), 2.4);
32013 else r /= 12.92;
32014 if (g > 0.04045) g = pow(((g + 0.055) / 1.055), 2.4);
32015 else g /= 12.92;
32016 if (b > 0.04045) b = pow(((b + 0.055) / 1.055), 2.4);
32017 else b /= 12.92;
32018
32019 double x = r * 0.4124 + g * 0.3576 + b * 0.1805;
32020 double y = r * 0.2126 + g * 0.7152 + b * 0.0722;
32021 double z = r * 0.0193 + g * 0.1192 + b * 0.9505;
32022
32023 if (x > 0.008856) x = pow(x, 1.0 / 3.0);
32024 else x = (7.787 * x) + (16.0 / 116.0);
32025 if (y > 0.008856) y = pow(y, 1.0 / 3.0);
32026 else y = (7.787 * y) + (16.0 / 116.0);
32027 if (z > 0.008856) z = pow(z, 1.0 / 3.0);
32028 else z = (7.787 * z) + (16.0 / 116.0);
32029
32030 double CIEL = (116 * y) - 16;
32031 double CIEa = 500 * (x - y);
32032 double CIEb = 200 * (y - z);
32033
32034 arr[0] = CIEL;
32035 arr[1] = CIEa;
32036 arr[2] = CIEb;
32037 break;
32038 }
32039 case CSPACE_LCH_CW:
32040 case CSPACE_LCH_CCW:
32041 case CSPACE_LCH:
32042 {
32043 if (r > 0.04045) r = pow(((r + 0.055) / 1.055), 2.4);
32044 else r /= 12.92;
32045 if (g > 0.04045) g = pow(((g + 0.055) / 1.055), 2.4);
32046 else g /= 12.92;
32047 if (b > 0.04045) b = pow(((b + 0.055) / 1.055), 2.4);
32048 else b /= 12.92;
32049
32050 double x = r * 0.4124 + g * 0.3576 + b * 0.1805;
32051 double y = r * 0.2126 + g * 0.7152 + b * 0.0722;
32052 double z = r * 0.0193 + g * 0.1192 + b * 0.9505;
32053
32054 if (x > 0.008856) x = pow(x, 1.0 / 3.0);
32055 else x = (7.787 * x) + (16.0 / 116.0);
32056 if (y > 0.008856) y = pow(y, 1.0 / 3.0);
32057 else y = (7.787 * y) + (16.0 / 116.0);
32058 if (z > 0.008856) z = pow(z, 1.0 / 3.0);
32059 else z = (7.787 * z) + (16.0 / 116.0);
32060
32061 double CIEL = (116 * y) - 16;
32062 double CIEa = 500 * (x - y);
32063 double CIEb = 200 * (y - z);
32064
32065 double h = atan2(CIEb, CIEa);
32066 if (h > 0) h = (h / PI) * 180;
32067 else h = 360 - (abs(h) / PI) * 180;
32068
32069 double CIEC = sqrt(pow(CIEa, 2) + pow(CIEb, 2));
32070
32071 arr[0] = CIEL;
32072 arr[1] = CIEC;
32073 arr[2] = h;
32074 break;
32075 }
32076 }
32077
32078 }
32079
32080 RGB user_paldata::RGBFrom(double arr[], int32_t color_space)
32081 {
32082 double r = 0.0;
32083 double g = 0.0;
32084 double b = 0.0;
32085 switch (color_space)
32086 {
32087 case CSPACE_CMYK:
32088 {
32089 double c = (arr[0] * (1 - arr[3]) + arr[3]);
32090 double m = (arr[1] * (1 - arr[3]) + arr[3]);
32091 double y = (arr[2] * (1 - arr[3]) + arr[3]);
32092
32093 r = vbound((1 - c) * 63.0, 0.0, 63.0);
32094 g = vbound((1 - m) * 63.0, 0.0, 63.0);
32095 b = vbound((1 - y) * 63.0, 0.0, 63.0);
32096 return _RGB(r, g, b);
32097 break;
32098 }
32099 case CSPACE_HSV_CW:
32100 case CSPACE_HSV_CCW:
32101 case CSPACE_HSV:
32102 {
32103 double h = arr[0];
32104 double s = arr[1];
32105 double v = arr[2];
32106
32107 if (s == 0)
32108 {
32109 r = v;
32110 g = v;
32111 b = v;
32112 }
32113 else
32114 {
32115 double var_h = h * 6;
32116 if (var_h >= 6) var_h = 0;
32117 int32_t var_i = floor(var_h);
32118 double var_1 = v * (1 - s);
32119 double var_2 = v * (1 - s * (var_h - var_i));
32120 double var_3 = v * (1 - s * (1 - (var_h - var_i)));
32121
32122 switch (var_i)
32123 {
32124 case 0:
32125 r = v;
32126 g = var_3;
32127 b = var_1;
32128 break;
32129 case 1:
32130 r = var_2;
32131 g = v;
32132 b = var_1;
32133 break;
32134 case 2:
32135 r = var_1;
32136 g = v;
32137 b = var_3;
32138 break;
32139 case 3:
32140 r = var_1;
32141 g = var_2;
32142 b = v;
32143 break;
32144 case 4:
32145 r = var_3;
32146 g = var_1;
32147 b = v;
32148 break;
32149 default:
32150 r = v;
32151 g = var_1;
32152 b = var_2;
32153 }
32154 }
32155
32156 r = vbound(r * 63.0, 0.0, 63.0);
32157 g = vbound(g * 63.0, 0.0, 63.0);
32158 b = vbound(b * 63.0, 0.0, 63.0);
32159
32160 return _RGB(r, g, b);
32161 }
32162 case CSPACE_HSL_CW:
32163 case CSPACE_HSL_CCW:
32164 case CSPACE_HSL:
32165 {
32166 double h = arr[0];
32167 double s = arr[1];
32168 double l = arr[2];
32169
32170 if (s == 0)
32171 {
32172 r = l;
32173 g = l;
32174 b = l;
32175 }
32176 else
32177 {
32178 double var_1;
32179 double var_2;
32180 if (l < 0.5)var_2 = l * (1 + s);
32181 else var_2 = (l + s) - (s * l);
32182
32183 var_1 = 2 * l - var_2;
32184
32185 r = HueToRGB(var_1, var_2, h + (1.0 / 3.0));
32186 g = HueToRGB(var_1, var_2, h);
32187 b = HueToRGB(var_1, var_2, h - (1.0 / 3.0));
32188 }
32189
32190 r = vbound(r * 63.0, 0.0, 63.0);
32191 g = vbound(g * 63.0, 0.0, 63.0);
32192 b = vbound(b * 63.0, 0.0, 63.0);
32193
32194 return _RGB(r, g, b);
32195 }
32196 case CSPACE_LAB:
32197 {
32198 double CIEL = arr[0];
32199 double CIEa = arr[1];
32200 double CIEb = arr[2];
32201
32202 double var_y = (CIEL + 16) / 116.0;
32203 double var_x = CIEa / 500.0 + var_y;
32204 double var_z = var_y - CIEb / 200.0;
32205
32206 if (pow(var_x, 3) > 0.008856) var_x = pow(var_x, 3);
32207 else var_x = (var_x - 16.0 / 116.0) / 7.787;
32208 if (pow(var_y, 3) > 0.008856) var_y = pow(var_y, 3);
32209 else var_y = (var_y - 16.0 / 116.0) / 7.787;
32210 if (pow(var_z, 3) > 0.008856) var_z = pow(var_z, 3);
32211 else var_z = (var_z - 16.0 / 116.0) / 7.787;
32212
32213 r = var_x * 3.2406 + var_y * -1.5372 + var_z * -0.4986;
32214 g = var_x * -0.9689 + var_y * 1.8758 + var_z * 0.0415;
32215 b = var_x * 0.0557 + var_y * -0.2040 + var_z * 1.0570;
32216
32217 if (r > 0.0031308) r = 1.055 * pow(r, (1 / 2.4)) - 0.055;
32218 else r = 12.92 * r;
32219 if (g > 0.0031308) g = 1.055 * pow(g, (1 / 2.4)) - 0.055;
32220 else g = 12.92 * g;
32221 if (b > 0.0031308) b = 1.055 * pow(b, (1 / 2.4)) - 0.055;
32222 else b = 12.92 * b;
32223
32224 r = vbound(r * 63.0, 0.0, 63.0);
32225 g = vbound(g * 63.0, 0.0, 63.0);
32226 b = vbound(b * 63.0, 0.0, 63.0);
32227
32228 return _RGB(r, g, b);
32229 }
32230 case CSPACE_LCH_CW:
32231 case CSPACE_LCH_CCW:
32232 case CSPACE_LCH:
32233 {
32234 double CIEL = arr[0];
32235 double CIEa = cos((arr[2] * PI) / 180.0) * arr[1];
32236 double CIEb = sin((arr[2] * PI) / 180.0) * arr[1];
32237
32238 double var_y = (CIEL + 16) / 116.0;
32239 double var_x = CIEa / 500.0 + var_y;
32240 double var_z = var_y - CIEb / 200.0;
32241
32242 if (pow(var_y, 3) > 0.008856) var_y = pow(var_y, 3);
32243 else var_y = (var_y - 16.0 / 116.0) / 7.787;
32244 if (pow(var_x, 3) > 0.008856) var_x = pow(var_x, 3);
32245 else var_x = (var_x - 16.0 / 116.0) / 7.787;
32246 if (pow(var_z, 3) > 0.008856) var_z = pow(var_z, 3);
32247 else var_z = (var_z - 16.0 / 116.0) / 7.787;
32248
32249 r = var_x * 3.2406 + var_y * -1.5372 + var_z * -0.4986;
32250 g = var_x * -0.9689 + var_y * 1.8758 + var_z * 0.0415;
32251 b = var_x * 0.0557 + var_y * -0.2040 + var_z * 1.0570;
32252
32253 if (r > 0.0031308) r = 1.055 * pow(r, (1 / 2.4)) - 0.055;
32254 else r = 12.92 * r;
32255 if (g > 0.0031308) g = 1.055 * pow(g, (1 / 2.4)) - 0.055;
32256 else g = 12.92 * g;
32257 if (b > 0.0031308) b = 1.055 * pow(b, (1 / 2.4)) - 0.055;
32258 else b = 12.92 * b;
32259
32260 r = vbound(r * 63.0, 0.0, 63.0);
32261 g = vbound(g * 63.0, 0.0, 63.0);
32262 b = vbound(b * 63.0, 0.0, 63.0);
32263
32264 return _RGB(r, g, b);
32265 }
32266 }
32267 return _RGB(0, 0, 0);
32268 }
32269 double user_paldata::HueToRGB(double v1, double v2, double vH)
32270 {
32271 if (vH < 0) vH += 1;
32272 if (vH > 1) vH -= 1;
32273 if ((6 * vH) < 1) return (v1 + (v2 - v1) * 6 * vH);
32274 if ((2 * vH) < 1) return (v2);
32275 if ((3 * vH) < 2) return (v1 + (v2 - v1) * ((2.0 / 3.0) - vH) * 6);
32276 return (v1);
32277 }
32278
32279 double user_paldata::WrapLerp(double a, double b, double t, double min, double max, int32_t direction)
32280 {
32281 double dif = abs(a - b);
32282 double range = abs(max - min);
32283
32284 switch (direction)
32285 {
32286 case 0:
32287 if (dif > range * 0.5)
32288 dif = range - dif;
32289 if (a + dif == b)
32290 direction = 1;
32291 else
32292 direction = -1;
32293 break;
32294 case 1:
32295 if (b < a)
32296 dif = range - dif;
32297 break;
32298 case -1:
32299 if (b > a)
32300 dif = range - dif;
32301 break;
32302 }
32303
32304 double ret = zc::math::Lerp(a, a + dif * direction, t);
32305
32306 if (ret <= min)
32307 ret += range;
32308 else if (ret >= max)
32309 ret -= range;
32310 return ret;
32311 }
32312
32313 //Mixes an entire palette given two paldatas
32314 void user_paldata::mix(user_paldata *pal_start, user_paldata *pal_end, double percent, int32_t color_space, int32_t start_color, int32_t end_color)
32315 {
32316 for (int32_t q = start_color; q < end_color; ++q)
32317 {
32318 if (get_bit(pal_start->colors_used, q) && get_bit(pal_end->colors_used, q)) {
32319 RGB start = pal_start->colors[q];
32320 RGB end = pal_end->colors[q];
32321 colors[q] = mix_color(start, end, percent, color_space);
32322 set_bit(colors_used, q, true);
32323 }
32324 }
32325 }
32326
32327 void item_display_name(const bool setter)
32328 {
32329 int32_t ID = ri->idata;
32330 if(unsigned(ID) >= MAXITEMS)
32331 return;
32332 int32_t arrayptr = get_register(sarg1) / 10000;
32333 if(setter)
32334 {
32335 std::string str;
32336 ArrayH::getString(arrayptr, str, 255);
32337 strcpy(itemsbuf[ID].display_name, str.c_str());
32338 }
32339 else
32340 {
32341 if(ArrayH::setArray(arrayptr, string(itemsbuf[ID].display_name)) == SH::_Overflow)
32342 Z_scripterrlog("Array supplied to 'itemdata->GetDisplayName()' not large enough\n");
32343 }
32344 }
32345 void item_shown_name()
32346 {
32347 int32_t ID = ri->idata;
32348 if(unsigned(ID) >= MAXITEMS)
32349 return;
32350 int32_t arrayptr = get_register(sarg1) / 10000;
32351 if(ArrayH::setArray(arrayptr, itemsbuf[ID].get_name()) == SH::_Overflow)
32352 Z_scripterrlog("Array supplied to 'itemdata->GetShownName()' not large enough\n");
32353 }
32354
32355 void FFScript::do_getDMapData_dmapname(const bool v)
32356 {
32357 //int32_t ID = ri->zmsgref;
32358 int32_t ID = ri->dmapsref;
32359 int32_t arrayptr = get_register(sarg1) / 10000;
32360
32361 if(BC::checkDMapID(ID, "dmapdata->GetName()") != SH::_NoError)
32362 return;
32363
32364 if(ArrayH::setArray(arrayptr, string(DMaps[ID].name)) == SH::_Overflow)
32365 Z_scripterrlog("Array supplied to 'dmapdata->GetName()' not large enough\n");
32366 }
32367
32368 void FFScript::do_setDMapData_dmapname(const bool v)
32369 {
32370 //int32_t ID = ri->zmsgref;
32371 int32_t ID = ri->dmapsref;
32372 int32_t arrayptr = get_register(sarg1) / 10000;
32373
32374 string filename_str;
32375
32376 if(BC::checkDMapID(ID, "dmapdata->SetName()") != SH::_NoError)
32377 return;
32378
32379
32380 ArrayH::getString(arrayptr, filename_str, 22);
32381 strncpy(DMaps[ID].name, filename_str.c_str(), 21);
32382 DMaps[ID].name[20]='\0';
32383 }
32384
32385 void FFScript::do_getDMapData_dmaptitle(const bool v)
32386 {
32387 //int32_t ID = ri->zmsgref;
32388 int32_t ID = ri->dmapsref;
32389 int32_t arrayptr = get_register(sarg1) / 10000;
32390
32391 if(BC::checkDMapID(ID, "dmapdata->GetTitle()") != SH::_NoError)
32392 return;
32393
32394 if (!get_qr(qr_OLD_DMAP_INTRO_STRINGS))
32395 {
32396 ArrayManager am(arrayptr);
32397 am.resize(DMaps[ID].title.size() + 1);
32398 }
32399 if(ArrayH::setArray(arrayptr, string(DMaps[ID].title)) == SH::_Overflow)
32400 Z_scripterrlog("Array supplied to 'dmapdata->GetTitle()' not large enough\n");
32401 }
32402
32403 void FFScript::do_setDMapData_dmaptitle(const bool v)
32404 {
32405 //int32_t ID = ri->zmsgref;
32406 int32_t ID = ri->dmapsref;
32407 int32_t arrayptr = get_register(sarg1) / 10000;
32408 string filename_str;
32409
32410 if(BC::checkDMapID(ID, "dmapdata->SetTitle()") != SH::_NoError)
32411 return;
32412
32413 if (get_qr(qr_OLD_DMAP_INTRO_STRINGS))
32414 {
32415 char namestr[21];
32416 ArrayH::getString(arrayptr, filename_str, 21);
32417 strncpy(namestr, filename_str.c_str(), 20);
32418 namestr[20] = '\0';
32419 DMaps[ID].title.assign(namestr);
32420 }
32421 else
32422 {
32423 ArrayH::getString(arrayptr, filename_str, ArrayH::getSize(arrayptr));
32424 DMaps[ID].title = filename_str;
32425 }
32426 }
32427
32428 void FFScript::do_getDMapData_dmapintro(const bool v)
32429 {
32430 //int32_t ID = ri->zmsgref;
32431 int32_t ID = ri->dmapsref;
32432 int32_t arrayptr = get_register(sarg1) / 10000;
32433
32434 if(BC::checkDMapID(ID, "dmapdata->GetIntro()") != SH::_NoError)
32435 return;
32436
32437 if(ArrayH::setArray(arrayptr, string(DMaps[ID].intro)) == SH::_Overflow)
32438 Z_scripterrlog("Array supplied to 'dmapdata->GetIntro()' not large enough\n");
32439 }
32440
32441 void FFScript::do_setDMapData_dmapintro(const bool v)
32442 {
32443 //int32_t ID = ri->zmsgref;
32444 int32_t ID = ri->dmapsref;
32445 int32_t arrayptr = get_register(sarg1) / 10000;
32446 string filename_str;
32447
32448 if(BC::checkDMapID(ID, "dmapdata->SetIntro()") != SH::_NoError)
32449 return;
32450
32451
32452 ArrayH::getString(arrayptr, filename_str, 73);
32453 strncpy(DMaps[ID].intro, filename_str.c_str(), 72);
32454 DMaps[ID].intro[72]='\0';
32455 }
32456
32457 void FFScript::do_getDMapData_music(const bool v)
32458 {
32459 //int32_t ID = ri->zmsgref;
32460 int32_t ID = ri->dmapsref;
32461 int32_t arrayptr = get_register(sarg1) / 10000;
32462
32463 if(BC::checkDMapID(ID, "dmapdata->GetMusic()") != SH::_NoError)
32464 return;
32465
32466 if(ArrayH::setArray(arrayptr, string(DMaps[ID].tmusic)) == SH::_Overflow)
32467 Z_scripterrlog("Array supplied to 'dmapdata->GetMusic()' not large enough\n");
32468 }
32469
32470 void FFScript::do_setDMapData_music(const bool v)
32471 {
32472 //int32_t ID = ri->zmsgref;
32473 int32_t ID = ri->dmapsref;
32474 int32_t arrayptr = get_register(sarg1) / 10000;
32475 string filename_str;
32476
32477 if(BC::checkDMapID(ID, "dmapdata->SetMusic()") != SH::_NoError)
32478 return;
32479
32480
32481 ArrayH::getString(arrayptr, filename_str, 56);
32482 strncpy(DMaps[ID].tmusic, filename_str.c_str(), 55);
32483 DMaps[ID].tmusic[55]='\0';
32484 }
32485
32486 void FFScript::do_loadnpcdata(const bool v)
32487 {
32488 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32489
32490 if ( ID < 1 || ID > (MAXGUYS-1) )
32491 {
32492 Z_scripterrlog("Invalid NPC ID passed to Game->LoadNPCData: %d\n", ID);
32493 ri->npcdataref = MAX_DWORD;
32494 }
32495
32496 else ri->npcdataref = ID;
32497 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
32498 }
32499 void FFScript::do_loadmessagedata(const bool v)
32500 {
32501 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32502
32503 if ( ID < 1 || ID > (msg_count-1) )
32504 {
32505 Z_scripterrlog("Invalid Message ID passed to Game->LoadMessageData: %d\n", ID);
32506 ri->zmsgref = MAX_DWORD;
32507 }
32508
32509 else ri->zmsgref = ID;
32510 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
32511 }
32512 //same syntax as loadmessage data
32513 //the input is an array
32514 void FFScript::do_messagedata_setstring(const bool v)
32515 {
32516 int32_t arrayptr = get_register(sarg1) / 10000;
32517 int32_t ID = ri->zmsgref;
32518 if(BC::checkMessage(ID, "messagesata->Set()") != SH::_NoError)
32519 return;
32520
32521 ArrayH::getString(arrayptr, MsgStrings[ID].s, MSG_NEW_SIZE);
32522 }
32523 void FFScript::do_messagedata_getstring(const bool v)
32524 {
32525 int32_t ID = ri->zmsgref;
32526 int32_t arrayptr = get_register(sarg1) / 10000;
32527
32528 if(BC::checkMessage(ID, "messagedata->Get()") != SH::_NoError)
32529 return;
32530
32531 if(ArrayH::setArray(arrayptr, MsgStrings[ID].s) == SH::_Overflow)
32532 Z_scripterrlog("Array supplied to 'messagedata->Get()' not large enough\n");
32533 }
32534
32535 25412 void FFScript::do_loadcombodata(const bool v)
32536 {
32537 25412 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32538
32539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25412 times.
25412 if ( (unsigned)ID > (MAXCOMBOS-1) )
32540 {
32541 Z_scripterrlog("Invalid Combo ID passed to Game->LoadComboData: %d\n", ID);
32542 ri->combosref = 0;
32543 }
32544
32545 25412 else ri->combosref = ID;
32546 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
32547 25412 }
32548
32549 void FFScript::do_loadmapdata(const bool v)
32550 {
32551 int32_t _map = SH::get_arg(sarg1, v) / 10000;
32552
32553 int32_t _scr = SH::get_arg(sarg2, v) / 10000;
32554 // zprint("LoadMapData Map Value: %d\n", _map);
32555 // zprint("LoadMapData Screen Value: %d\n", _scr);
32556 int32_t indx = (_map * MAPSCRS + _scr);
32557 // zprint("LoadMapData Indx Value: %d\n", indx);
32558 if ( _map < 1 || _map > (map_count-1) )
32559 {
32560 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", _map);
32561 ri->mapsref = 0;
32562 }
32563 else if ( (unsigned)_scr > 129 ) //0x00 to 0x81 -Z
32564 {
32565 Z_scripterrlog("Invalid Screen ID passed to Game->LoadMapData: %d\n", _scr);
32566 ri->mapsref = 0;
32567 }
32568 else ri->mapsref = indx;
32569 // zprint("LoadMapData Screen set ri->mapsref to: %d\n", ri->mapsref);
32570 //zprint("Script loaded mapdata with ID = %ld\n", ri->idata);
32571 }
32572
32573 403497 void FFScript::do_loadmapdata_tempscr(const bool v)
32574 {
32575 403497 int32_t layer = SH::get_arg(sarg1, v) / 10000;
32576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403497 times.
403497 if(BC::checkBounds(layer, 0, 6, "Game->LoadTempScreen()") != SH::_NoError)
32577 {
32578 ri->mapsref = 0;
32579 return;
32580 }
32581
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 89778 times.
✓ Branch 2 taken 118147 times.
✓ Branch 3 taken 102973 times.
✓ Branch 4 taken 915 times.
✓ Branch 5 taken 91682 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
403497 switch(layer)
32582 {
32583 89778 case 0: ri->mapsref = MAPSCR_TEMP0; break;
32584 118147 case 1: ri->mapsref = MAPSCR_TEMP1; break;
32585 102973 case 2: ri->mapsref = MAPSCR_TEMP2; break;
32586 915 case 3: ri->mapsref = MAPSCR_TEMP3; break;
32587 91682 case 4: ri->mapsref = MAPSCR_TEMP4; break;
32588 1 case 5: ri->mapsref = MAPSCR_TEMP5; break;
32589 1 case 6: ri->mapsref = MAPSCR_TEMP6; break;
32590 }
32591 403497 set_register(sarg1, ri->mapsref);
32592 403497 }
32593
32594 177544 void FFScript::do_loadmapdata_scrollscr(const bool v)
32595 {
32596 177544 int32_t layer = SH::get_arg(sarg1, v) / 10000;
32597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177544 times.
177544 if(BC::checkBounds(layer, 0, 6, "Game->LoadScrollingScreen()") != SH::_NoError)
32598 {
32599 ri->mapsref = 0;
32600 return;
32601 }
32602
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 88755 times.
✓ Branch 2 taken 88755 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
177544 switch(layer)
32603 {
32604 88755 case 0: ri->mapsref = MAPSCR_SCROLL0; break;
32605 88755 case 1: ri->mapsref = MAPSCR_SCROLL1; break;
32606 case 2: ri->mapsref = MAPSCR_SCROLL2; break;
32607 case 3: ri->mapsref = MAPSCR_SCROLL3; break;
32608 34 case 4: ri->mapsref = MAPSCR_SCROLL4; break;
32609 case 5: ri->mapsref = MAPSCR_SCROLL5; break;
32610 case 6: ri->mapsref = MAPSCR_SCROLL6; break;
32611 }
32612 177544 set_register(sarg1, ri->mapsref);
32613 177544 }
32614
32615 void FFScript::do_loadshopdata(const bool v)
32616 {
32617 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32618
32619 if ( (unsigned)ID > 255 )
32620 {
32621 Z_scripterrlog("Invalid Shop ID passed to Game->LoadShopData: %d\n", ID);
32622 ri->shopsref = 0;
32623 }
32624 else ri->shopsref = ID;
32625 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
32626 }
32627
32628
32629 void FFScript::do_loadinfoshopdata(const bool v)
32630 {
32631 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32632
32633 if ( (unsigned)ID > 255 )
32634 {
32635 Z_scripterrlog("Invalid Shop ID passed to Game->LoadShopData: %d\n", ID);
32636 ri->shopsref = 0;
32637 }
32638 else ri->shopsref = ID+NUMSHOPS;
32639 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
32640 }
32641
32642 /*
32643 void FFScript::do_loadmapdata(const bool v)
32644 {
32645 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32646
32647 if ( ID < 0 || ID > (map_count-1) )
32648 {
32649 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", ID);
32650 ri->mapsref = MAX_SIGNED_32;
32651 }
32652
32653 else ri->mapsref = ID;
32654 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
32655 }
32656 */
32657
32658 /*
32659
32660 void FFScript::do_loadmapdata(const bool v)
32661 {
32662 int32_t ID = get_register(sarg2) / 10000;
32663
32664 if ( ID < 0 || ID > (map_count-1) )
32665 {
32666 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", ID);
32667 return;
32668 }
32669
32670 ri->mapsref = ID;
32671 set_register(sarg1, ri->mapsref);
32672 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
32673 }
32674
32675 */
32676
32677 void FFScript::do_loadspritedata(const bool v)
32678 {
32679 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32680
32681 if ( (unsigned)ID > (MAXWPNS-1) )
32682 {
32683 Z_scripterrlog("Invalid Sprite ID passed to Game->LoadSpriteData: %d\n", ID);
32684 ri->spritesref = 0;
32685 }
32686
32687 else ri->spritesref = ID;
32688 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
32689 }
32690
32691
32692 void FFScript::do_loadscreendata(const bool v)
32693 {
32694 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32695
32696 if ( (unsigned)ID > (MAXSCREENS-1) )
32697 {
32698 Z_scripterrlog("Invalid Map ID passed to Game->LoadScreenData: %d\n", ID);
32699 ri->screenref = 0;
32700 }
32701
32702 else ri->screenref = ID;
32703 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
32704 }
32705
32706 void FFScript::do_loadbitmapid(const bool v)
32707 {
32708 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32709 switch(ID)
32710 {
32711 case -1:
32712 case 0:
32713 case 1:
32714 case 2:
32715 case 3:
32716 case 4:
32717 case 5:
32718 case 6:
32719 ri->bitmapref = ID+10; break;
32720 default:
32721 {
32722 Z_scripterrlog("Invalid Bitmap ID passed to Game->Load BitmapID: %d\n", ID);
32723 ri->bitmapref = 0; break;
32724 }
32725 }
32726
32727 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
32728 }
32729
32730 77262 void do_createlweapon(const bool v)
32731 {
32732 77262 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
32733
32734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77262 times.
77262 if(BC::checkWeaponID(ID, "Screen->CreateLWeapon") != SH::_NoError)
32735 return;
32736
32737
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
77262 if ( Lwpns.has_space() )
32738 {
32739 77262 Lwpns.add
32740 (
32741
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
154524 new weapon
32742 (
32743
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
77262 (zfix)0, /*X*/
32744
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
77262 (zfix)0, /*Y*/
32745
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
77262 (zfix)0, /*Z*/
32746 77262 ID, /*id*/
32747 0, /*type*/
32748 0, /*power*/
32749 0, /*dir*/
32750 -1, /*Parentid*/
32751
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
77262 Hero.getUID(), /*prntid*/
32752 false, /*isdummy*/
32753 1, /*script_gen*/
32754 1, /*islwpn*/
32755 77262 (ID==wWind?1:0) /*special*/
32756 )
32757 );
32758 77262 ri->lwpn = Lwpns.spr(Lwpns.Count() - 1)->getUID();
32759 //Lwpns.spr(Lwpns.Count() - 1)->LOADGFX(0);
32760 //Lwpns.spr(Lwpns.Count() - 1)->ScriptGenerated = 1;
32761 //Lwpns.spr(Lwpns.Count() - 1)->isLWeapon = 1;
32762 77262 weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //last created
32763 //w->LOADGFX(FFCore.getDefWeaponSprite(ID)); //No.
32764 77262 w->ScriptGenerated = 1;
32765 77262 w->isLWeapon = 1;
32766
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
77262 if(ID == wWind) w->specialinfo = 1;
32767 77262 Z_eventlog("Script created lweapon %ld with UID = %ld\n", ID, ri->lwpn);
32768 77262 }
32769 else
32770 {
32771 //ri->lwpn = MAX_DWORD;
32772 ri->lwpn = 0; // Now NULL
32773 Z_scripterrlog("Couldn't create lweapon %ld, screen lweapon limit reached\n", ID);
32774 }
32775 77262 }
32776
32777 131917 void do_createeweapon(const bool v)
32778 {
32779 131917 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
32780
32781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131917 times.
131917 if(BC::checkWeaponID(ID, "Screen->CreateEWeapon") != SH::_NoError)
32782 return;
32783
32784
1/2
✓ Branch 0 taken 131917 times.
✗ Branch 1 not taken.
131917 if ( Ewpns.has_space() )
32785 {
32786 131917 addEwpn(0, 0, 0, ID, 0, 0, 0, -1,1); //Param 9 marks it as script-generated.
32787 //Ewpns.spr(Ewpns.Count() - 1)->LOADGFX(0);
32788 //Ewpns.spr(Ewpns.Count() - 1)->ScriptGenerated = 1;
32789 //Ewpns.spr(Ewpns.Count() - 1)->isLWeapon = 0;
32790
4/6
✓ Branch 0 taken 122104 times.
✓ Branch 1 taken 9813 times.
✓ Branch 2 taken 122104 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 122104 times.
✗ Branch 5 not taken.
131917 if( ID > wEnemyWeapons || ( ID >= wScript1 && ID <= wScript10) )
32791 {
32792 131917 weapon *w = (weapon*)Ewpns.spr(Ewpns.Count()-1); //last created
32793 //w->LOADGFX(FFCore.getDefWeaponSprite(ID));
32794 131917 w->ScriptGenerated = 1;
32795 131917 w->isLWeapon = 0;
32796 131917 ri->ewpn = Ewpns.spr(Ewpns.Count() - 1)->getUID();
32797 131917 Z_eventlog("Script created eweapon %ld with UID = %ld\n", ID, ri->ewpn);
32798 131917 }
32799 else
32800 {
32801 Z_scripterrlog("Couldn't create eweapon %ld: Invalid ID/Type (%d) specified.\n", ID);
32802 return;
32803 }
32804 131917 }
32805 else
32806 {
32807 ri->ewpn = 0;
32808 Z_scripterrlog("Couldn't create eweapon %ld, screen eweapon limit reached\n", ID);
32809 }
32810 131917 }
32811
32812 21343 void do_createitem(const bool v)
32813 {
32814 21343 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
32815
32816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21343 times.
21343 if(BC::checkItemID(ID, "Screen->CreateItem") != SH::_NoError)
32817 return;
32818
32819
1/2
✓ Branch 0 taken 21343 times.
✗ Branch 1 not taken.
21343 if ( items.has_space() )
32820 {
32821 21343 additem(0, (get_qr(qr_NOITEMOFFSET) ? 1: 0), ID, ipBIGRANGE);
32822 21343 ri->itemref = items.spr(items.Count() - 1)->getUID();
32823 21343 Z_eventlog("Script created item \"%s\" with UID = %ld\n", item_string[ID], ri->itemref);
32824 21343 }
32825 else
32826 {
32827 ri->itemref = 0;
32828 Z_scripterrlog("Couldn't create item \"%s\", screen item limit reached\n", item_string[ID]);
32829 }
32830 /*
32831 if(items.Count() < 1)
32832 {
32833 ri->itemref = MAX_DWORD;
32834 Z_scripterrlog("Couldn't create item \"%s\", screen item limit reached\n", item_string[ID]);
32835 }
32836 else
32837 {
32838 ri->itemref = items.spr(items.Count() - 1)->getUID();
32839 Z_eventlog("Script created item \"%s\" with UID = %ld\n", item_string[ID], ri->itemref);
32840 }
32841 */
32842 21343 }
32843
32844 2363 void do_createnpc(const bool v)
32845 {
32846 2363 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
32847
32848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2363 times.
2363 if(BC::checkGuyID(ID, "Screen->CreateNPC") != SH::_NoError)
32849 return;
32850
32851 //If we make a segmented enemy there'll be more than one sprite created
32852 2363 word numcreated = addenemy(0, 0, ID, -10);
32853
32854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2363 times.
2363 if(numcreated == 0)
32855 {
32856 //ri->guyref = MAX_DWORD;
32857 ri->guyref = 0;
32858 Z_scripterrlog("Couldn't create NPC \"%s\", screen NPC limit reached\n", guy_string[ID]);
32859 }
32860 else
32861 {
32862 2363 word index = guys.Count() - numcreated; //Get the main enemy, not a segment
32863 2363 ri->guyref = guys.spr(index)->getUID();
32864
32865
2/2
✓ Branch 0 taken 2399 times.
✓ Branch 1 taken 2363 times.
4762 for(; index<guys.Count(); index++)
32866 2399 ((enemy*)guys.spr(index))->script_spawned=true;
32867
32868 2363 Z_eventlog("Script created NPC \"%s\" with UID = %ld\n", guy_string[ID], ri->guyref);
32869 }
32870 2363 }
32871
32872 ///----------------------------------------------------------------------------------------------------//
32873 //Drawing & Sound
32874
32875 173 void do_message(const bool v)
32876 {
32877 173 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
32878
32879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 173 times.
173 if(BC::checkMessage(ID, "Screen->Message") != SH::_NoError)
32880 return;
32881
32882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 173 times.
173 if(ID == 0)
32883 {
32884 dismissmsg();
32885 msgfont = get_zc_font(font_zfont);
32886 blockpath = false;
32887 Hero.finishedmsg();
32888 }
32889 else
32890 173 donewmsg(ID);
32891 173 }
32892
32893 37261285 INLINE void set_drawing_command_args(const int32_t j, const word numargs)
32894 {
32895
2/2
✓ Branch 0 taken 293934713 times.
✓ Branch 1 taken 37261285 times.
331195998 for(int32_t k = 1; k <= numargs; k++)
32896 293934713 script_drawing_commands[j][k] = SH::read_stack(ri->sp + (numargs - k));
32897 37261285 }
32898
32899 648786 INLINE void set_user_bitmap_command_args(const int32_t j, const word numargs)
32900 {
32901 //ri->bitmapref = SH::read_stack(ri->sp+numargs);
32902 //zprint("Current drawing bitmap ref is: %d\n", ri->bitmapref );
32903
2/2
✓ Branch 0 taken 6987552 times.
✓ Branch 1 taken 648786 times.
7636338 for(int32_t k = 1; k <= numargs; k++)
32904 6987552 script_drawing_commands[j][k] = SH::read_stack(ri->sp + (numargs - k));
32905 648786 }
32906
32907 37910071 void do_drawing_command(const int32_t script_command)
32908 {
32909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37910071 times.
37910071 if (FFCore.skipscriptdraws)
32910 return;
32911 37910071 int32_t j = script_drawing_commands.GetNext();
32912
32913
1/2
✓ Branch 0 taken 37910071 times.
✗ Branch 1 not taken.
37910071 if(j == -1) //out of drawing command space
32914 {
32915 Z_scripterrlog("Max draw primitive limit reached\n");
32916 return;
32917 }
32918
32919 37910071 script_drawing_commands[j][0] = script_command;
32920 37910071 script_drawing_commands[j][18] = zscriptDrawingRenderTarget->GetCurrentRenderTarget(); // no fixed bs.
32921
32922
36/76
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6363 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2198272 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1056651 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1850 times.
✓ Branch 9 taken 937398 times.
✓ Branch 10 taken 383247 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 826175 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1718027 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 4737314 times.
✓ Branch 21 taken 17997642 times.
✓ Branch 22 taken 936091 times.
✓ Branch 23 taken 94003 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 9270 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 802244 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 4128276 times.
✓ Branch 30 taken 49303 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1240874 times.
✓ Branch 34 taken 144648 times.
✓ Branch 35 taken 7806 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 18927 times.
✓ Branch 38 taken 2600 times.
✓ Branch 39 taken 26528 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✓ Branch 43 taken 1480 times.
✗ Branch 44 not taken.
✓ Branch 45 taken 502 times.
✓ Branch 46 taken 144 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 80910 times.
✓ Branch 49 taken 59173 times.
✗ Branch 50 not taken.
✓ Branch 51 taken 821 times.
✗ Branch 52 not taken.
✓ Branch 53 taken 162686 times.
✓ Branch 54 taken 784 times.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✓ Branch 58 taken 45504 times.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✓ Branch 63 taken 1152 times.
✗ Branch 64 not taken.
✓ Branch 65 taken 229546 times.
✓ Branch 66 taken 906 times.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✓ Branch 70 taken 906 times.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
37910071 switch(script_command)
32923 {
32924 case RECTR:
32925 2198272 set_drawing_command_args(j, 12);
32926 2198272 break;
32927
32928 case FRAMER:
32929 set_drawing_command_args(j, 9);
32930 break;
32931
32932 case CIRCLER:
32933 1056651 set_drawing_command_args(j, 11);
32934 1056651 break;
32935
32936 case ARCR:
32937 set_drawing_command_args(j, 14);
32938 break;
32939
32940 case ELLIPSER:
32941 1850 set_drawing_command_args(j, 12);
32942 1850 break;
32943
32944 case LINER:
32945 937398 set_drawing_command_args(j, 11);
32946 937398 break;
32947
32948 case PUTPIXELR:
32949 383247 set_drawing_command_args(j, 8);
32950 383247 break;
32951
32952 case PIXELARRAYR:
32953 {
32954 set_drawing_command_args(j, 5);
32955 std::vector<int32_t> *v = script_drawing_commands.GetVector();
32956 //for ( int32_t q = 0; q < 6; q++ )
32957 //{
32958 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
32959 //}
32960 int32_t arrayptr = script_drawing_commands[j][2]/10000;
32961 if ( !arrayptr ) //Don't crash because of vector size.
32962 {
32963 Z_scripterrlog("Invalid array pointer %d passed to Screen->PutPixels(). Aborting.", arrayptr);
32964 break;
32965 }
32966 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
32967 int32_t sz = ArrayH::getSize(arrayptr);
32968 if(!sz)
32969 {
32970 script_drawing_commands.PopLast();
32971 return;
32972 }
32973 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
32974 //zprint("Pixelarray size is: %d\n", sz);
32975 v->resize(sz, 0);
32976 int32_t* pos = &v->at(0);
32977
32978 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
32979 script_drawing_commands[j].SetVector(v);
32980 break;
32981 }
32982
32983 case TILEARRAYR:
32984 {
32985 set_drawing_command_args(j, 2);
32986 std::vector<int32_t> *v = script_drawing_commands.GetVector();
32987 //for ( int32_t q = 0; q < 6; q++ )
32988 //{
32989 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
32990 //}
32991 int32_t arrayptr = script_drawing_commands[j][2]/10000;
32992 if ( !arrayptr ) //Don't crash because of vector size.
32993 {
32994 Z_scripterrlog("Invalid array pointer %d passed to Screen->DrawTiles(). Aborting.", arrayptr);
32995 break;
32996 }
32997 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
32998 int32_t sz = ArrayH::getSize(arrayptr);
32999 if(!sz)
33000 {
33001 script_drawing_commands.PopLast();
33002 return;
33003 }
33004 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
33005 //zprint("Pixelarray size is: %d\n", sz);
33006 v->resize(sz, 0);
33007 int32_t* pos = &v->at(0);
33008
33009 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
33010 script_drawing_commands[j].SetVector(v);
33011 break;
33012 }
33013
33014 case LINESARRAY:
33015 {
33016 set_drawing_command_args(j, 2);
33017 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33018 //for ( int32_t q = 0; q < 6; q++ )
33019 //{
33020 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
33021 //}
33022 int32_t arrayptr = script_drawing_commands[j][2]/10000;
33023 if ( !arrayptr ) //Don't crash because of vector size.
33024 {
33025 Z_scripterrlog("Invalid array pointer %d passed to Screen->Lines(). Aborting.", arrayptr);
33026 break;
33027 }
33028 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
33029 int32_t sz = ArrayH::getSize(arrayptr);
33030 if(!sz)
33031 {
33032 script_drawing_commands.PopLast();
33033 return;
33034 }
33035 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
33036 //zprint("Pixelarray size is: %d\n", sz);
33037 v->resize(sz, 0);
33038 int32_t* pos = &v->at(0);
33039
33040 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
33041 script_drawing_commands[j].SetVector(v);
33042 break;
33043 }
33044
33045 /*
33046 historical-old-master
33047 set_drawing_command_args(j, 6);
33048 int32_t count = script_drawing_commands[j][2] / 10000; //todo: errcheck
33049
33050 int32_t* ptr = (int32_t*)script_drawing_commands.AllocateDrawBuffer(3 * count * sizeof(int32_t));
33051 int32_t* p = ptr;
33052
33053 ArrayH::getValues(script_drawing_commands[j][3] / 10000, p, count); p += count;
33054 ArrayH::getValues(script_drawing_commands[j][4] / 10000, p, count); p += count;
33055 ArrayH::getValues(script_drawing_commands[j][5] / 10000, p, count);
33056
33057 script_drawing_commands[j].SetPtr(ptr);
33058 */
33059 // Unused
33060 //const int32_t index = script_drawing_commands[j][19] = j;
33061
33062 //std::array *aptr = script_drawing_commands.GetString();
33063 //ArrayH::getString(script_drawing_commands[j][2] / 10000, *aptr);
33064 //script_drawing_commands[j].SetArray(aptr);
33065 //set_drawing_command_args(j, 2);
33066 //break;
33067
33068 case COMBOARRAYR:
33069 {
33070 set_drawing_command_args(j, 2);
33071 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33072 //for ( int32_t q = 0; q < 6; q++ )
33073 //{
33074 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
33075 //}
33076 int32_t arrayptr = script_drawing_commands[j][2]/10000;
33077 if ( !arrayptr ) //Don't crash because of vector size.
33078 {
33079 Z_scripterrlog("Invalid array pointer %d passed to Screen->DrawCombos(). Aborting.", arrayptr);
33080 break;
33081 }
33082 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
33083 int32_t sz = ArrayH::getSize(arrayptr);
33084 if(!sz)
33085 {
33086 script_drawing_commands.PopLast();
33087 return;
33088 }
33089 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
33090 //zprint("Pixelarray size is: %d\n", sz);
33091 v->resize(sz, 0);
33092 int32_t* pos = &v->at(0);
33093
33094 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
33095 script_drawing_commands[j].SetVector(v);
33096 break;
33097 }
33098 case POLYGONR:
33099 {
33100 set_drawing_command_args(j, 5);
33101
33102 int32_t arrayptr = script_drawing_commands[j][3]/10000;
33103 if ( !arrayptr ) //Don't crash because of vector size.
33104 {
33105 Z_scripterrlog("Invalid array pointer %d passed to Screen->Polygon(). Aborting.", arrayptr);
33106 break;
33107 }
33108 int32_t sz = ArrayH::getSize(arrayptr);
33109 if(!sz)
33110 {
33111 script_drawing_commands.PopLast();
33112 return;
33113 }
33114
33115 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33116 v->resize(sz, 0);
33117
33118 int32_t* pos = &v->at(0);
33119
33120
33121 ArrayH::getValues(script_drawing_commands[j][3] / 10000, pos, sz);
33122 script_drawing_commands[j].SetVector(v);
33123 }
33124 break;
33125
33126 case DRAWTILER:
33127 826175 set_drawing_command_args(j, 15);
33128 826175 break;
33129
33130 case DRAWTILECLOAKEDR:
33131 set_drawing_command_args(j, 7);
33132 break;
33133
33134 case DRAWCOMBOR:
33135 1718027 set_drawing_command_args(j, 16);
33136 1718027 break;
33137
33138 case DRAWCOMBOCLOAKEDR:
33139 set_drawing_command_args(j, 7);
33140 break;
33141
33142 case FASTTILER:
33143 4737314 set_drawing_command_args(j, 6);
33144 4737314 break;
33145
33146 case FASTCOMBOR:
33147 17997642 set_drawing_command_args(j, 6);
33148 17997642 break;
33149
33150 case DRAWCHARR:
33151 936091 set_drawing_command_args(j, 10);
33152 936091 break;
33153
33154 case DRAWINTR:
33155 94003 set_drawing_command_args(j, 11);
33156 94003 break;
33157
33158 case SPLINER:
33159 set_drawing_command_args(j, 11);
33160 break;
33161
33162 case QUADR:
33163 9270 set_drawing_command_args(j, 15);
33164 9270 break;
33165
33166 case TRIANGLER:
33167 set_drawing_command_args(j, 13);
33168 break;
33169
33170 case BITMAPR:
33171 802244 set_drawing_command_args(j, 12);
33172 802244 break;
33173
33174 case BITMAPEXR:
33175 set_drawing_command_args(j, 16);
33176 break;
33177
33178 case DRAWLAYERR:
33179 4128276 set_drawing_command_args(j, 8);
33180 4128276 break;
33181
33182 case DRAWSCREENR:
33183 49303 set_drawing_command_args(j, 6);
33184 49303 break;
33185
33186 case QUAD3DR:
33187 {
33188 set_drawing_command_args(j, 8);
33189 int32_t arrayptr = script_drawing_commands[j][2]/10000;
33190 int32_t sz = ArrayH::getSize(arrayptr);
33191 arrayptr = script_drawing_commands[j][3]/10000;
33192 sz += ArrayH::getSize(arrayptr);
33193 arrayptr = script_drawing_commands[j][4]/10000;
33194 sz += ArrayH::getSize(arrayptr);
33195 arrayptr = script_drawing_commands[j][5]/10000;
33196 sz += ArrayH::getSize(arrayptr);
33197 if(sz < 25)
33198 {
33199 script_drawing_commands.PopLast();
33200 return;
33201 }
33202 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33203 v->resize(sz, 0);
33204
33205 int32_t* pos = &v->at(0);
33206 int32_t* uv = &v->at(12);
33207 int32_t* col = &v->at(20);
33208 int32_t* size = &v->at(24);
33209
33210 ArrayH::getValues((script_drawing_commands[j][2] / 10000), pos, 12);
33211 ArrayH::getValues((script_drawing_commands[j][3] / 10000), uv, 8);
33212 ArrayH::getValues((script_drawing_commands[j][4] / 10000), col, 4);
33213 //FFCore.getValues2(script_drawing_commands[j][5] / 10000, size, 2);
33214 ArrayH::getValues((script_drawing_commands[j][5] / 10000), size, 2);
33215
33216 script_drawing_commands[j].SetVector(v);
33217 }
33218 break;
33219
33220 case TRIANGLE3DR:
33221 {
33222 set_drawing_command_args(j, 8);
33223
33224 int32_t arrayptr = script_drawing_commands[j][2]/10000;
33225 int32_t sz = ArrayH::getSize(arrayptr);
33226 arrayptr = script_drawing_commands[j][3]/10000;
33227 sz += ArrayH::getSize(arrayptr);
33228 arrayptr = script_drawing_commands[j][4]/10000;
33229 sz += ArrayH::getSize(arrayptr);
33230 arrayptr = script_drawing_commands[j][5]/10000;
33231 sz += ArrayH::getSize(arrayptr);
33232 if(sz < 19)
33233 {
33234 script_drawing_commands.PopLast();
33235 return;
33236 }
33237
33238 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33239 v->resize(sz, 0);
33240
33241 int32_t* pos = &v->at(0);
33242 int32_t* uv = &v->at(9);
33243 int32_t* col = &v->at(15);
33244 int32_t* size = &v->at(18);
33245
33246 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, 8);
33247 ArrayH::getValues(script_drawing_commands[j][3] / 10000, uv, 6);
33248 ArrayH::getValues(script_drawing_commands[j][4] / 10000, col, 3);
33249 ArrayH::getValues(script_drawing_commands[j][5] / 10000, size, 2);
33250
33251 script_drawing_commands[j].SetVector(v);
33252 }
33253 break;
33254
33255 case DRAWSTRINGR:
33256 {
33257 1240874 set_drawing_command_args(j, 9);
33258 // Unused
33259 //const int32_t index = script_drawing_commands[j][19] = j;
33260
33261 1240874 string *str = script_drawing_commands.GetString();
33262 1240874 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
33263 1240874 script_drawing_commands[j].SetString(str);
33264 }
33265 1240874 break;
33266
33267 case DRAWSTRINGR2:
33268 {
33269 144648 set_drawing_command_args(j, 11);
33270 // Unused
33271 //const int32_t index = script_drawing_commands[j][19] = j;
33272
33273 144648 string *str = script_drawing_commands.GetString();
33274 144648 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
33275 144648 script_drawing_commands[j].SetString(str);
33276 }
33277 144648 break;
33278
33279 case BMPRECTR:
33280 7806 set_user_bitmap_command_args(j, 12); script_drawing_commands[j][17] = SH::read_stack(ri->sp+12);
33281 //Pop the args off the stack first. Then pop the pointer and push it to sdci[17].
33282 //The pointer for the bitmap variable (its literal value) is always ri->sp+numargs, so, with 12 args, it is sp+12.
33283 7806 break;
33284
33285 case BMPFRAMER:
33286 set_user_bitmap_command_args(j, 9);
33287 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
33288 break;
33289
33290 case CLEARBITMAP:
33291 {
33292 18927 set_user_bitmap_command_args(j, 1);
33293 18927 script_drawing_commands[j][17] = SH::read_stack(ri->sp+1);
33294 18927 break;
33295 }
33296 case BITMAPCLEARTOCOLOR:
33297 {
33298 2600 set_user_bitmap_command_args(j, 2);
33299 2600 script_drawing_commands[j][17] = SH::read_stack(ri->sp+2);
33300 2600 break;
33301 }
33302 case REGENERATEBITMAP:
33303 {
33304 26528 set_user_bitmap_command_args(j, 3);
33305 26528 script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
33306 26528 break;
33307 }
33308 case BMPPOLYGONR:
33309 {
33310 set_user_bitmap_command_args(j, 5);
33311 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
33312 int32_t arrayptr = script_drawing_commands[j][3]/10000;
33313 if ( !arrayptr ) //Don't crash because of vector size.
33314 {
33315 Z_scripterrlog("Invalid array pointer %d passed to Screen->Polygon(). Aborting.", arrayptr);
33316 break;
33317 }
33318 int32_t sz = ArrayH::getSize(arrayptr);
33319 if(!sz)
33320 {
33321 script_drawing_commands.PopLast();
33322 return;
33323 }
33324 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33325 v->resize(sz, 0);
33326
33327 int32_t* pos = &v->at(0);
33328
33329
33330 ArrayH::getValues(script_drawing_commands[j][3] / 10000, pos, sz);
33331 script_drawing_commands[j].SetVector(v);
33332 }
33333 break;
33334 case READBITMAP:
33335 {
33336 //zprint("Calling %s\n","READBITMAP");
33337 set_user_bitmap_command_args(j, 2);
33338 script_drawing_commands[j][17] = SH::read_stack(ri->sp+2);
33339 string *str = script_drawing_commands.GetString();
33340 ArrayH::getString(script_drawing_commands[j][2] / 10000, *str, 256);
33341
33342 //char cptr = new char[str->size()+1]; // +1 to account for \0 byte
33343 //strncpy(cptr, str->c_str(), str->size());
33344
33345 if(get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE))
33346 {
33347 char buf[2048+1] = {0};
33348 if(FFCore.get_scriptfile_path(buf, str->c_str()))
33349 (*str) = buf;
33350 }
33351 regulate_path(*str);
33352
33353 //zprint("READBITMAP string is %s\n", cptr);
33354
33355 script_drawing_commands[j].SetString(str);
33356 break;
33357 }
33358 case WRITEBITMAP:
33359 {
33360 //zprint("Calling %s\n","WRITEBITMAP");
33361 set_user_bitmap_command_args(j, 3);
33362 script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
33363 std::string *str = script_drawing_commands.GetString();
33364 ArrayH::getString(script_drawing_commands[j][2] / 10000, *str, 256);
33365
33366
33367 //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte
33368 //strncpy(cptr, str->c_str(), str->size());
33369
33370 if(get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE))
33371 {
33372 char buf[2048+1] = {0};
33373 if(FFCore.get_scriptfile_path(buf, str->c_str()))
33374 (*str) = buf;
33375 }
33376 regulate_path(*str);
33377
33378 //zprint("WRITEBITMAP string is %s\n", cptr);
33379 script_drawing_commands[j].SetString(str);
33380 break;
33381 }
33382
33383 1480 case BMPCIRCLER: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
33384 case BMPARCR: set_user_bitmap_command_args(j, 14); script_drawing_commands[j][17] = SH::read_stack(ri->sp+14); break;
33385 502 case BMPELLIPSER: set_user_bitmap_command_args(j, 12); script_drawing_commands[j][17] = SH::read_stack(ri->sp+12); break;
33386 144 case BMPLINER: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
33387 case BMPSPLINER: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
33388 80910 case BMPPUTPIXELR: set_user_bitmap_command_args(j, 8); script_drawing_commands[j][17] = SH::read_stack(ri->sp+8); break;
33389 59173 case BMPDRAWTILER: set_user_bitmap_command_args(j, 15); script_drawing_commands[j][17] = SH::read_stack(ri->sp+15); break;
33390 case BMPDRAWTILECLOAKEDR: set_user_bitmap_command_args(j, 7); script_drawing_commands[j][17] = SH::read_stack(ri->sp+7); break;
33391 821 case BMPDRAWCOMBOR: set_user_bitmap_command_args(j, 16); script_drawing_commands[j][17] = SH::read_stack(ri->sp+16); break;
33392 case BMPDRAWCOMBOCLOAKEDR: set_user_bitmap_command_args(j, 7); script_drawing_commands[j][17] = SH::read_stack(ri->sp+7); break;
33393 162686 case BMPFASTTILER: set_user_bitmap_command_args(j, 6); script_drawing_commands[j][17] = SH::read_stack(ri->sp+6); break;
33394 784 case BMPFASTCOMBOR: set_user_bitmap_command_args(j, 6); script_drawing_commands[j][17] = SH::read_stack(ri->sp+6); break;
33395 case BMPDRAWCHARR: set_user_bitmap_command_args(j, 10); script_drawing_commands[j][17] = SH::read_stack(ri->sp+10); break;
33396 case BMPDRAWINTR: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
33397 case BMPDRAWSTRINGR:
33398 {
33399 set_user_bitmap_command_args(j, 9);
33400 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
33401 // Unused
33402 //const int32_t index = script_drawing_commands[j][19] = j;
33403
33404 string *str = script_drawing_commands.GetString();
33405 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
33406 script_drawing_commands[j].SetString(str);
33407
33408 }
33409 break;
33410 case BMPDRAWSTRINGR2:
33411 {
33412 45504 set_user_bitmap_command_args(j, 11);
33413 45504 script_drawing_commands[j][17] = SH::read_stack(ri->sp+11);
33414 // Unused
33415 //const int32_t index = script_drawing_commands[j][19] = j;
33416
33417 45504 string *str = script_drawing_commands.GetString();
33418 45504 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
33419 45504 script_drawing_commands[j].SetString(str);
33420
33421 }
33422 45504 break;
33423 case BMPQUADR: set_user_bitmap_command_args(j, 16); script_drawing_commands[j][17] = SH::read_stack(ri->sp+16); break;
33424 case BMPQUAD3DR:
33425 {
33426 set_drawing_command_args(j, 9);
33427 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33428 v->resize(26, 0);
33429
33430 int32_t* pos = &v->at(0);
33431 int32_t* uv = &v->at(12);
33432 int32_t* col = &v->at(20);
33433 int32_t* size = &v->at(24);
33434
33435
33436 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, 12);
33437 ArrayH::getValues(script_drawing_commands[j][3] / 10000, uv, 8);
33438 ArrayH::getValues(script_drawing_commands[j][4] / 10000, col, 4);
33439 ArrayH::getValues(script_drawing_commands[j][5] / 10000, size, 2);
33440
33441 script_drawing_commands[j].SetVector(v);
33442 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
33443
33444 }
33445 break;
33446 case BMPTRIANGLER: set_user_bitmap_command_args(j, 14); script_drawing_commands[j][17] = SH::read_stack(ri->sp+14); break;
33447 case BMPTRIANGLE3DR:
33448 {
33449 set_drawing_command_args(j, 9);
33450
33451 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33452 v->resize(20, 0);
33453
33454 int32_t* pos = &v->at(0);
33455 int32_t* uv = &v->at(9);
33456 int32_t* col = &v->at(15);
33457 int32_t* size = &v->at(18);
33458
33459
33460 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, 8);
33461 ArrayH::getValues(script_drawing_commands[j][3] / 10000, uv, 6);
33462 ArrayH::getValues(script_drawing_commands[j][4] / 10000, col, 3);
33463 ArrayH::getValues(script_drawing_commands[j][5] / 10000, size, 2);
33464
33465 script_drawing_commands[j].SetVector(v);
33466 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
33467 break;
33468 }
33469
33470 case BMPDRAWLAYERR:
33471 1152 set_user_bitmap_command_args(j, 8);
33472 1152 script_drawing_commands[j][17] = SH::read_stack(ri->sp+8);
33473 1152 break;
33474 case BMPDRAWLAYERSOLIDR:
33475 case BMPDRAWLAYERCFLAGR:
33476 case BMPDRAWLAYERCTYPER:
33477 case BMPDRAWLAYERCIFLAGR:
33478 case BMPDRAWLAYERSOLIDITYR: set_user_bitmap_command_args(j, 9); script_drawing_commands[j][17] = SH::read_stack(ri->sp+9); break;
33479 case BMPDRAWSCREENR:
33480 case BMPDRAWSCREENSOLIDR:
33481 case BMPDRAWSCREENSOLID2R:
33482 case BMPDRAWSCREENCOMBOFR:
33483 case BMPDRAWSCREENCOMBOIR:
33484 case BMPDRAWSCREENCOMBOTR:
33485 2048 set_user_bitmap_command_args(j, 6); script_drawing_commands[j][17] = SH::read_stack(ri->sp+6); break;
33486 case BITMAPGETPIXEL:
33487 {
33488 //UNUSED
33489 // for(int32_t q = 0; q < 20; q++)
33490 // {
33491 // Z_scripterrlog("getpixel SH::read_stack(ri->sp+%d) is: %d\n", q, SH::read_stack(ri->sp+q));
33492 // }
33493 set_user_bitmap_command_args(j, 3); script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
33494 break;
33495 }
33496 case BMPBLIT:
33497 {
33498 229546 set_user_bitmap_command_args(j, 16);
33499 //for(int32_t q = 0; q < 8; ++q )
33500 //Z_scripterrlog("FFscript blit() ri->d[%d] is: %d\n", q, ri->d[q]);
33501 229546 script_drawing_commands[j][17] = SH::read_stack(ri->sp+16);
33502 229546 break;
33503 }
33504 case BMPBLITTO:
33505 {
33506 906 set_user_bitmap_command_args(j, 16);
33507 //for(int32_t q = 0; q < 8; ++q )
33508 //Z_scripterrlog("FFscript blit() ri->d[%d] is: %d\n", q, ri->d[q]);
33509 906 script_drawing_commands[j][17] = SH::read_stack(ri->sp+16);
33510 906 break;
33511 }
33512 case BMPMODE7:
33513 {
33514 set_user_bitmap_command_args(j, 13);
33515 //for(int32_t q = 0; q < 8; ++q )
33516 //Z_scripterrlog("FFscript blit() ri->d[%d] is: %d\n", q, ri->d[q]);
33517 script_drawing_commands[j][17] = SH::read_stack(ri->sp+13);
33518 break;
33519 }
33520
33521 case BMPWRITETILE:
33522 {
33523 set_user_bitmap_command_args(j, 6);
33524 script_drawing_commands[j][17] = SH::read_stack(ri->sp+6);
33525 break;
33526 }
33527 case BMPDITHER:
33528 {
33529 set_user_bitmap_command_args(j, 5);
33530 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
33531 break;
33532 }
33533 case BMPMASKDRAW:
33534 {
33535 906 set_user_bitmap_command_args(j, 3);
33536 906 script_drawing_commands[j][4] = 0x01 * 10000L;
33537 906 script_drawing_commands[j][5] = 0xFF * 10000L;
33538 906 script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
33539 906 break;
33540 }
33541 case BMPMASKDRAW2:
33542 {
33543 set_user_bitmap_command_args(j, 4);
33544 script_drawing_commands[j][5] = script_drawing_commands[j][4];
33545 script_drawing_commands[j][0] = BMPMASKDRAW;
33546 script_drawing_commands[j][17] = SH::read_stack(ri->sp+4);
33547 break;
33548 }
33549 case BMPMASKDRAW3:
33550 {
33551 set_user_bitmap_command_args(j, 5);
33552 script_drawing_commands[j][0] = BMPMASKDRAW;
33553 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
33554 break;
33555 }
33556 case BMPMASKBLIT:
33557 {
33558 set_user_bitmap_command_args(j, 4);
33559 script_drawing_commands[j][5] = 0x01 * 10000L;
33560 script_drawing_commands[j][6] = 0xFF * 10000L;
33561 script_drawing_commands[j][17] = SH::read_stack(ri->sp+4);
33562 break;
33563 }
33564 case BMPMASKBLIT2:
33565 {
33566 set_user_bitmap_command_args(j, 5);
33567 script_drawing_commands[j][6] = script_drawing_commands[j][5];
33568 script_drawing_commands[j][0] = BMPMASKBLIT;
33569 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
33570 break;
33571 }
33572 case BMPMASKBLIT3:
33573 {
33574 set_user_bitmap_command_args(j, 6);
33575 script_drawing_commands[j][0] = BMPMASKBLIT;
33576 script_drawing_commands[j][17] = SH::read_stack(ri->sp+6);
33577 break;
33578 }
33579 case BMPREPLCOLOR:
33580 case BMPSHIFTCOLOR:
33581 {
33582 6363 set_user_bitmap_command_args(j, 4);
33583 6363 script_drawing_commands[j][17] = SH::read_stack(ri->sp+4);
33584 6363 break;
33585 }
33586 }
33587 37910071 script_drawing_commands.mark_dirty(script_drawing_commands[j][1]/10000);
33588 37910071 }
33589
33590 3535588 void do_set_rendertarget(bool)
33591 {
33592 3535588 int32_t target = int32_t(SH::read_stack(ri->sp) / 10000);
33593 3535588 zscriptDrawingRenderTarget->SetCurrentRenderTarget(target);
33594 3535588 }
33595
33596 170875 void do_sfx(const bool v)
33597 {
33598 170875 int32_t ID = SH::get_arg(sarg1, v) / 10000;
33599
33600
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 170871 times.
170875 if(BC::checkSFXID(ID, "Game->PlaySound") != SH::_NoError)
33601 4 return;
33602
33603 170871 sfx(ID);
33604 170875 }
33605
33606 void do_sfx_ex(const bool restart)
33607 {
33608 int32_t ID = SH::read_stack(ri->sp + 4) / 10000;
33609 int32_t vol = vbound(SH::read_stack(ri->sp + 3), 0, 10000 * 100);
33610 int32_t pan = vbound(SH::read_stack(ri->sp + 2)/10000 + 128, 0, 255);
33611 int32_t freq = SH::read_stack(ri->sp + 1);
33612 bool loop = SH::read_stack(ri->sp) / 10000;
33613
33614 if (BC::checkSFXID(ID, restart?"Audio->PlaySound":"Audio->AdjustSound") != SH::_NoError)
33615 return;
33616
33617 if (!restart && !sfx_allocated(ID))
33618 return;
33619
33620 sfx(ID, pan, loop, restart, vol, freq);
33621 }
33622
33623 static int get_sfx_completion()
33624 {
33625 int32_t ID = get_register(sarg1) / 10000;
33626
33627 if (!sfx_allocated(ID))
33628 {
33629 return -10000;
33630 }
33631
33632 uint64_t sample_pos = voice_get_position(sfx_voice[ID]);
33633
33634 if (sample_pos < 0)
33635 {
33636 return -10000;
33637 }
33638
33639 uint32_t sample_length = sfx_get_length(ID);
33640 uint64_t res = (sample_pos * 10000 * 100) / sample_length;
33641 return int32_t(res);
33642 }
33643
33644 void do_get_sfx_completion()
33645 {
33646 int32_t ID = get_register(sarg1) / 10000;
33647 if (replay_is_active())
33648 replay_step_comment(fmt::format("ID {}", ID));
33649 int32_t value = replay_get_state(ReplayStateType::SfxPosition, get_sfx_completion);
33650 set_register(sarg1, value);
33651 }
33652
33653 int32_t FFScript::do_get_internal_uid_npc(int32_t index)
33654 {
33655 return ((int32_t)guys.spr(index)->getUID());
33656 }
33657 int32_t FFScript::do_get_internal_uid_item(int32_t index)
33658 {
33659 return ((int32_t)items.spr(index)->getUID());
33660 }
33661 int32_t FFScript::do_get_internal_uid_lweapon(int32_t index)
33662 {
33663 return ((int32_t)Lwpns.spr(index)->getUID());
33664 }
33665 int32_t FFScript::do_get_internal_uid_eweapon(int32_t index)
33666 {
33667 return ((int32_t)Ewpns.spr(index)->getUID());
33668 }
33669
33670 void FFScript::AlloffLimited(int32_t flagset)
33671 {
33672 clear_bitmap(msg_txt_display_buf);
33673 clear_bitmap(msg_bg_display_buf);
33674 clear_bitmap(msg_portrait_display_buf);
33675 set_clip_state(msg_txt_display_buf, 1);
33676 set_clip_state(msg_bg_display_buf, 1);
33677 set_clip_state(msg_portrait_display_buf, 1);
33678
33679
33680 clear_bitmap(pricesdisplaybuf);
33681 set_clip_state(pricesdisplaybuf, 1);
33682
33683 if(items.idCount(iPile))
33684 {
33685 loadlvlpal(DMaps[currdmap].color);
33686 }
33687
33688 /*
33689
33690 #define warpFlagCLEARITEMS 0x200
33691 #define warpFlagCLEARGUYS 0x400
33692 #define warpFlagCLEARLWEAPONS 0x800
33693 #define warpFlagCLEAREWEAPONS 0x1000
33694 #define warpFlagCLEARHOOKSHOT 0x2000
33695 #define warpFlagCLEARDECORATIONS 0x4000
33696 #define warpFlagCLEARPARTICLES 0x8000
33697 */
33698
33699 if ( (flagset&warpFlagCLEARITEMS) ) items.clear();
33700 if ( (flagset&warpFlagCLEARGUYS) ) guys.clear();
33701 if ( (flagset&warpFlagCLEARLWEAPONS) ) Lwpns.clear();
33702 if ( (flagset&warpFlagCLEAREWEAPONS) ) Ewpns.clear();
33703 if ( (flagset&warpFlagCLEARHOOKSHOT) )
33704 {
33705 chainlinks.clear();
33706 Hero.reset_hookshot();
33707 }
33708 if ( (flagset&warpFlagCLEARDECORATIONS) ) decorations.clear();
33709 if ( (flagset&warpFlagCLEARPARTICLES) ) particles.clear();
33710 clearScriptHelperData();
33711
33712
33713
33714 clearScriptHelperData();
33715
33716 lensclk = 0;
33717 lensid=-1;
33718 drawguys=true;
33719 down_control_states[btnUp] =
33720 down_control_states[btnDown] =
33721 down_control_states[btnLeft] =
33722 down_control_states[btnRight] =
33723 down_control_states[btnA] =
33724 down_control_states[btnB] =
33725 down_control_states[btnS] = true;
33726
33727 if(watch && !cheat_superman)
33728 {
33729 Hero.setClock(false);
33730 }
33731
33732 // if(watch)
33733 // Hero.setClock(false);
33734 watch=freeze_guys=loaded_guys=loaded_enemies=blockpath=false;
33735
33736 for(int32_t i=0; i<176; i++)
33737 guygrid[i]=0;
33738
33739 for(int32_t i=0; i<MAXFFCS; i++)
33740 guygridffc[i]=0;
33741
33742
33743 sle_clk=0;
33744
33745 if(usebombpal)
33746 {
33747 memcpy(RAMpal, tempbombpal, PAL_SIZE*sizeof(RGB));
33748 refreshpal=true;
33749 usebombpal=false;
33750 }
33751
33752
33753 }
33754
33755 32 void doWarpEffect(int32_t warpEffect, bool out)
33756 {
33757
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
32 switch(warpEffect)
33758 {
33759 case warpEffectZap:
33760 if(out) zapout();
33761 else zapin();
33762 break;
33763 case warpEffectWave:
33764 if(out) wavyout(false);
33765 else wavyin();
33766 break;
33767 case warpEffectInstant:
33768 if(out) blackscr(30,true);
33769 break;
33770 case warpEffectMozaic:
33771 //!TODO Unimplemented
33772 break;
33773 case warpEffectOpen:
33774 if(out) closescreen();
33775 else openscreen();
33776 break;
33777 }
33778 32 }
33779
33780 void FFScript::queueWarp(int32_t wtype, int32_t tdm, int32_t tscr, int32_t wx, int32_t wy,
33781 int32_t weff, int32_t wsfx, int32_t wflag, int32_t wdir)
33782 {
33783 warpex[wexActive] = 1;
33784 warpex[wexType] = wtype;
33785 warpex[wexDMap] = tdm;
33786 warpex[wexScreen] = tscr;
33787 warpex[wexX] = wx;
33788 warpex[wexY] = wy;
33789 warpex[wexEffect] = weff;
33790 warpex[wexSound] = wsfx;
33791 warpex[wexFlags] = wflag;
33792 warpex[wexDir] = wdir;
33793 }
33794
33795 16 bool FFScript::warp_player(int32_t warpType, int32_t dmapID, int32_t scrID, int32_t warpDestX, int32_t warpDestY, int32_t warpEffect, int32_t warpSound, int32_t warpFlags, int32_t heroFacesDir)
33796 {
33797 if(DEVLOGGING)
33798 {
33799 zprint("FFScript::warp_player() arg %s is: %d \n", "warpType", warpType);
33800 zprint("FFScript::warp_player() arg %s is: %d \n", "dmapID", dmapID);
33801 zprint("FFScript::warp_player() arg %s is: %d \n", "scrID", scrID);
33802 zprint("FFScript::warp_player() arg %s is: %d \n", "warpDestX", warpDestX);
33803 zprint("FFScript::warp_player() arg %s is: %d \n", "warpDestY", warpDestY);
33804 zprint("FFScript::warp_player() arg %s is: %d \n", "warpEffect", warpEffect);
33805 zprint("FFScript::warp_player() arg %s is: %d \n", "warpSound", warpSound);
33806 zprint("FFScript::warp_player() arg %s is: %d \n", "warpFlags", warpFlags);
33807 zprint("FFScript::warp_player() arg %s is: %d \n", "heroFacesDir", heroFacesDir);
33808 }
33809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)dmapID) >= MAXDMAPS )
33810 {
33811 Z_scripterrlog("Invalid DMap ID (%d) passed to WarpEx(). Aborting.\n", dmapID);
33812 return false;
33813 }
33814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)scrID) >= MAPSCRS )
33815 {
33816 Z_scripterrlog("Invalid Screen ID (%d) passed to WarpEx(). Aborting.\n", scrID);
33817 return false;
33818 }
33819 //Extra sanity guard.
33820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( DMaps[dmapID].map*MAPSCRS+DMaps[dmapID].xoff+scrID >= (int32_t)TheMaps.size() )
33821 {
33822 Z_scripterrlog("Invalid destination passed to WarpEx(). Aborting.\n");
33823 return false;
33824 }
33825 16 byte t = 0;
33826 16 t=(currscr<128)?0:1;
33827 16 bool overlay=false;
33828 16 bool intradmap = (dmapID == currdmap);
33829 16 int32_t olddmap = currdmap;
33830 //if ( intradmap )
33831 //{
33832 // initZScriptDMapScripts(); //Not needed.
33833 //}
33834
33835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( warpType == wtNOWARP ) { Z_eventlog("Used a Cancel Warped to DMap %d: %s, screen %d", currdmap, DMaps[currdmap].name,currscr); return false; }
33836 16 int32_t mapID = (DMaps[dmapID].map+1);
33837 16 int32_t dest_dmap_xoff = DMaps[dmapID].xoff;
33838 //mapscr *m = &TheMaps[mapID * MAPSCRS + scrID];
33839
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 mapscr *m = &TheMaps[(zc_max((mapID)-1,0) * MAPSCRS + dest_dmap_xoff + scrID)];
33840
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( warpFlags&warpFlagNOSTEPFORWARD ) FFCore.temp_no_stepforward = 1;
33841 16 int32_t wx = 0, wy = 0;
33842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( warpDestX < 0 )
33843 {
33844 if(DEVLOGGING) zprint("WarpEx() was set to warp return point:%d\n", warpDestY);
33845
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (unsigned)warpDestY < 4 )
33846 {
33847 16 wx = m->warpreturnx[warpDestY];
33848 16 wy = m->warpreturny[warpDestY];
33849 if(DEVLOGGING)
33850 {
33851 zprint("WarpEx Return Point X is: %d\n",wx);
33852 zprint("WarpEx Return Point Y is: %d\n",wy);
33853 }
33854 16 }
33855 else
33856 {
33857 if ( warpDestY == 5 || warpDestY < 0)
33858 {
33859 //Pit warp
33860 wx = Hero.getX();
33861 wy = Hero.getY();
33862 }
33863 else
33864 {
33865 Z_scripterrlog("Invalid Warp Return Square Type (%d) provided as an arg to Player->WarpEx().\n",warpDestY);
33866 return false;
33867 }
33868 }
33869 16 }
33870 else
33871 {
33872 if ( (unsigned)warpDestX < 256 && (unsigned)warpDestY < 176 )
33873 {
33874 wx = warpDestX;
33875 wy = warpDestY;
33876 }
33877 else
33878 {
33879 Z_scripterrlog("Invalid pixel coordinates of x = %d, y = %d, supplied to Player->WarpEx()\n",warpDestX,warpDestY);
33880 return false;
33881 }
33882
33883 }
33884 //zprint("FFCore.warp_player reached line: %d \n", 15918);
33885 //warp coordinates are wx, wy, not x, y! -Z
33886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLSCRIPTDRAWS) ) script_drawing_commands.Clear();
33887 //we also need to check if dmaps are sideview here! -Z
33888 //Likewise, we need to add that check to the normal Hero:;dowarp(0
33889 16 bool wasSideview = isSideViewGravity(t); //((tmpscr[t].flags7 & fSIDEVIEW)!=0 || DMaps[currdmap].sideview) && !ignoreSideview;
33890 //zprint("FFCore.warp_player reached line: %d \n", 15925);
33891 //zprint("FFCore.warp_player war type is: %d \n", warpType);
33892
33893 //int32_t last_entr_scr = -1;
33894 //int32_t last_entr_dmap = -1;
33895
33896
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( warpType < wtEXIT ) warpType = wtIWARP; //Sanity check. We can't use wtCave, or wtPassage, with scritped warps at present.
33897 16 Hero.is_warping = true;
33898
1/5
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
16 switch(warpType)
33899 {
33900
33901 //wtCAVE, wtPASS, wtEXIT, wtSCROLL, wtIWARP, wtIWARPBLK, wtIWARPOPEN,
33902 //wtIWARPZAP, wtIWARPWAVE, wtNOWARP, wtWHISTLE, wtMAX
33903
33904
33905 case wtIWARP:
33906 case wtIWARPBLK:
33907 case wtIWARPOPEN:
33908 case wtIWARPZAP:
33909 case wtIWARPWAVE:
33910 {
33911 //zprint("FFCore.warp_player reached line: %d \n", 15936);
33912 16 bool wasswimming = (Hero.getAction()==swimming);
33913 16 bool wassideswim = (Hero.getAction()==sideswimming);
33914 16 int32_t olddiveclk = Hero.diveclk;
33915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTCLEARSPRITES) )
33916 {
33917 16 ALLOFF();
33918 16 }
33919 else FFCore.AlloffLimited(warpFlags);
33920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLMUSIC) ) music_stop();
33921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLSOUNDS) ) kill_sfx();
33922 16 sfx(warpSound);
33923
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(wasswimming)
33924 {
33925 Hero.setAction(swimming); FFCore.setHeroAction(swimming);
33926 Hero.diveclk = olddiveclk;
33927 }
33928
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(wassideswim)
33929 {
33930 Hero.setAction(sideswimming); FFCore.setHeroAction(sideswimming);
33931 Hero.diveclk = 0;
33932 }
33933 //zprint("FFCore.warp_player reached line: %d \n", 15948);
33934 16 doWarpEffect(warpEffect, true);
33935 //zprint("FFCore.warp_player reached line: %d \n", 15973);
33936 16 int32_t c = DMaps[currdmap].color;
33937 16 bool changedlevel = false;
33938 16 bool changeddmap = false;
33939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(currdmap != dmapID)
33940 {
33941 16 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
33942 16 changeddmap = true;
33943 16 }
33944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(dlevel != DMaps[dmapID].level)
33945 {
33946 16 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
33947 16 changedlevel = true;
33948 16 }
33949 16 dlevel = DMaps[dmapID].level;
33950 16 currdmap = dmapID;
33951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(changeddmap)
33952 {
33953 16 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
33954 16 }
33955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(changedlevel)
33956 {
33957 16 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
33958 16 }
33959 16 currmap = DMaps[currdmap].map;
33960 16 init_dmap();
33961 16 update_subscreens(dmapID);
33962
33963 16 ringcolor(false);
33964
33965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(DMaps[currdmap].color != c)
33966 16 loadlvlpal(DMaps[currdmap].color);
33967
33968 16 homescr = currscr = scrID + DMaps[currdmap].xoff;
33969
33970 16 lightingInstant(); // Also sets naturaldark
33971
33972 16 loadscr(0,currdmap,currscr,-1,overlay);
33973
33974 16 Hero.x = (zfix)wx;
33975 16 Hero.y = (zfix)wy;
33976
33977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 switch(heroFacesDir)
33978 {
33979 case up:
33980 case down:
33981 case left:
33982 case right:
33983 Hero.dir = heroFacesDir;
33984 break;
33985 default:
33986
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.x==(zfix)0)
33987 {
33988 Hero.dir=right;
33989 }
33990
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.x==(zfix)240)
33991 {
33992 Hero.dir=left;
33993 }
33994
33995
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.y==(zfix)0)
33996 {
33997 Hero.dir=down;
33998 }
33999
34000
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.y==(zfix)160)
34001 {
34002 Hero.dir=up;
34003 }
34004 16 }
34005
34006 16 markBmap(Hero.dir^1);
34007
34008
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
16 if(iswaterex(MAPCOMBO((int32_t)Hero.x,(int32_t)Hero.y+8), currmap, currscr, -1, Hero.x, Hero.y+8, true) && _walkflag((int32_t)Hero.x,(int32_t)Hero.y+8,0) && current_item(itype_flippers))
34009 {
34010 Hero.hopclk=0xFF;
34011 Hero.attackclk = Hero.charging = Hero.spins = 0;
34012 if (isSideViewHero() && get_qr(qr_SIDESWIM)) {Hero.setAction(sideswimming); FFCore.setHeroAction(sideswimming);}
34013 else {Hero.setAction(swimming); FFCore.setHeroAction(swimming);}
34014 }
34015 else
34016 {
34017 16 Hero.setAction(none); FFCore.setHeroAction(none);
34018 }
34019
34020 //preloaded freeform combos
34021 16 ffscript_engine(true);
34022
34023 16 putscr(scrollbuf,0,0,tmpscr);
34024 16 putscrdoors(scrollbuf,0,0,tmpscr);
34025
34026 16 doWarpEffect(warpEffect, false);
34027 16 show_subscreen_life=true;
34028 16 show_subscreen_numbers=true;
34029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLMUSIC) ) Play_Level_Music();
34030 16 currcset=DMaps[currdmap].color;
34031 16 dointro();
34032 16 Hero.set_respawn_point();
34033 16 Hero.trySideviewLadder();
34034
34035 16 break;
34036 }
34037
34038
34039 case wtEXIT:
34040 {
34041 //zprint("%s was called with a warp type of Entrance/Exit\n", "Player->WarpEx()");
34042 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
34043 ALLOFF();
34044 if ( !(warpFlags&warpFlagDONTKILLMUSIC) ) music_stop();
34045 if ( !(warpFlags&warpFlagDONTKILLSOUNDS) ) kill_sfx();
34046 sfx(warpSound);
34047 blackscr(30,false);
34048 bool changedlevel = false;
34049 bool changeddmap = false;
34050 if(currdmap != dmapID)
34051 {
34052 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
34053 changeddmap = true;
34054 }
34055 if(dlevel != DMaps[dmapID].level)
34056 {
34057 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
34058 changedlevel = true;
34059 }
34060 dlevel = DMaps[dmapID].level;
34061 currdmap = dmapID;
34062 if(changeddmap)
34063 {
34064 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
34065 }
34066 if(changedlevel)
34067 {
34068 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
34069 }
34070 currmap=DMaps[currdmap].map;
34071 init_dmap();
34072 update_subscreens(dmapID);
34073 loadfullpal();
34074 ringcolor(false);
34075 loadlvlpal(DMaps[currdmap].color);
34076 //lastentrance_dmap = currdmap;
34077 homescr = currscr = scrID + DMaps[currdmap].xoff;
34078 loadscr(0,currdmap,currscr,-1,overlay);
34079
34080 if((tmpscr->flags&fDARK) && !get_qr(qr_NEW_DARKROOM))
34081 {
34082 if(get_qr(qr_FADE))
34083 {
34084 interpolatedfade();
34085 }
34086 else
34087 {
34088 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
34089 }
34090
34091 darkroom=naturaldark=true;
34092 }
34093 else
34094 {
34095 darkroom=naturaldark=false;
34096 }
34097
34098
34099 //Move Player's coordinates
34100 Hero.x = (zfix)wx;
34101 Hero.y = (zfix)wy;
34102 //set his dir
34103 switch(heroFacesDir)
34104 {
34105 case up:
34106 case down:
34107 case left:
34108 case right:
34109 Hero.dir = heroFacesDir;
34110 break;
34111 default:
34112 Hero.dir=down;
34113 if((int32_t)Hero.x==(zfix)0)
34114 {
34115 Hero.dir=right;
34116 }
34117 if((int32_t)Hero.x==(zfix)240)
34118 {
34119 Hero.dir=left;
34120 }
34121
34122 if((int32_t)Hero.y==(zfix)0)
34123 {
34124 Hero.dir=down;
34125 }
34126
34127 if((int32_t)Hero.y==(zfix)160)
34128 {
34129 Hero.dir=up;
34130 }
34131 }
34132
34133 if(dlevel)
34134 {
34135 // reset enemy kill counts
34136 for(int32_t i=0; i<128; i++)
34137 {
34138 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
34139 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
34140 }
34141 }
34142
34143 markBmap(Hero.dir^1);
34144 //preloaded freeform combos
34145 ffscript_engine(true);
34146 Hero.reset_hookshot();
34147
34148 if(isdungeon())
34149 {
34150 openscreen();
34151 if(get_er(er_SHORTDGNWALK)==0 && get_qr(qr_SHORTDGNWALK)==0)
34152 Hero.stepforward(Hero.diagonalMovement?11:12, false);
34153 else
34154 // Didn't walk as far pre-1.93, and some quests depend on that
34155 Hero.stepforward(8, false);
34156 }
34157 else
34158 {
34159 openscreen();
34160 }
34161
34162 show_subscreen_life=true;
34163 show_subscreen_numbers=true;
34164 Play_Level_Music();
34165 currcset=DMaps[currdmap].color;
34166 dointro();
34167 Hero.set_respawn_point();
34168 Hero.trySideviewLadder();
34169
34170 for(int32_t i=0; i<6; i++)
34171 visited[i]=-1;
34172
34173 //last_entr_scr = scrID;
34174 //last_entr_dmap = dmapID;
34175
34176 break;
34177
34178 }
34179 case wtSCROLL: // scrolling warp
34180 {
34181 int32_t c = DMaps[currdmap].color;
34182 scrolling_map = currmap;
34183 currmap = DMaps[dmapID].map;
34184 update_subscreens(dmapID);
34185
34186 dlevel = DMaps[dmapID].level;
34187 //check if Hero has the map for the new location before updating the subscreen. ? -Z
34188 //This works only in one direction, if Hero had a map, to not having one.
34189 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
34190 update_subscreens(dmapID);
34191
34192 // if ( has_item(itype_map, dlevel) )
34193 // {
34194 // //Blank the map during an intra-dmap scrolling warp.
34195 // dlevel = -1; //a hack for the minimap. This works!! -Z
34196 // }
34197
34198 // fix the scrolling direction, if it was a tile or instant warp
34199 Hero.sdir = vbound(Hero.dir,0,3);
34200
34201
34202 Hero.scrollscr(Hero.sdir, scrID+DMaps[dmapID].xoff, dmapID);
34203 bool changedlevel = false;
34204 bool changeddmap = false;
34205 if(currdmap != dmapID)
34206 {
34207 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
34208 changeddmap = true;
34209 }
34210 if(dlevel != DMaps[dmapID].level)
34211 {
34212 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
34213 changedlevel = true;
34214 }
34215 dlevel = DMaps[dmapID].level;
34216 currdmap = dmapID;
34217 if(changeddmap)
34218 {
34219 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
34220 }
34221 if(changedlevel)
34222 {
34223 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
34224 }
34225
34226 Hero.reset_hookshot();
34227
34228 if(!intradmap)
34229 {
34230 currdmap = dmapID;
34231 dlevel = DMaps[currdmap].level;
34232 homescr = currscr = scrID + DMaps[dmapID].xoff;
34233 init_dmap();
34234
34235
34236 if(((wx>0||wy>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!get_qr(qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
34237 {
34238 if(dlevel)
34239 {
34240 lastentrance = currscr;
34241 }
34242 else
34243 {
34244 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
34245 }
34246
34247 lastentrance_dmap = dmapID;
34248 }
34249 }
34250
34251 if(DMaps[currdmap].color != c)
34252 {
34253 lighting(false, true);
34254 }
34255
34256 Play_Level_Music();
34257 currcset=DMaps[currdmap].color;
34258 dointro();
34259 break;
34260 }
34261 //Cannot use these types with scripts, or with strings.
34262 case wtCAVE:
34263 case wtPASS:
34264 case wtWHISTLE:
34265 default:
34266 {
34267 Z_scripterrlog("Invalid warp type (%d) supplied to Hero->WarpEx()!. Cannot warp!!\n", warpType);
34268 Hero.is_warping = false;
34269 return false;
34270 }
34271 }
34272 // Stop Hero from drowning!
34273
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(Hero.getAction()==drowning)
34274 {
34275 Hero.drownclk=0;
34276 Hero.setAction(none); FFCore.setHeroAction(none);
34277 }
34278
34279 // But keep him swimming if he ought to be!
34280
3/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
16 if(Hero.getAction()!=rafting && iswaterex(MAPCOMBO((int32_t)Hero.x,(int32_t)Hero.y+8), currmap, currscr, -1, Hero.x, Hero.y+8, true) && (_walkflag((int32_t)Hero.x,(int32_t)Hero.y+8,0) || get_qr(qr_DROWN))
34281 && (current_item(itype_flippers)) && (Hero.getAction()!=inwind))
34282 {
34283 Hero.hopclk=0xFF;
34284 if (isSideViewHero() && get_qr(qr_SIDESWIM)) {Hero.setAction(sideswimming); FFCore.setHeroAction(sideswimming);}
34285 else {Hero.setAction(swimming); FFCore.setHeroAction(swimming);}
34286 }
34287
34288 16 newscr_clk=frame;
34289 16 activated_timed_warp=false;
34290 16 eat_buttons();
34291
34292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(warpType!=wtIWARP) { Hero.attackclk=0; }
34293
34294 16 Hero.didstuff=0;
34295 16 Hero.usecounts.clear();
34296 16 map_bkgsfx(true);
34297 16 loadside=Hero.dir^1;
34298 16 whistleclk=-1;
34299
34300
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if(((int32_t)Hero.z>0 || (int32_t)Hero.fakez>0) && isSideViewHero())
34301 {
34302 Hero.y-=Hero.z;
34303 Hero.y-=Hero.fakez;
34304 Hero.z=0;
34305 Hero.fakez=0;
34306 }
34307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 else if(!isSideViewHero())
34308 {
34309 16 Hero.fall=0;
34310 16 Hero.fakefall=0;
34311 16 }
34312
34313 // If warping between top-down and sideview screens,
34314 // fix enemies that are carried over by Full Screen Warp
34315 16 const bool tmpscr_is_sideview = isSideViewGravity();
34316
34317
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if(!wasSideview && tmpscr_is_sideview)
34318 {
34319 for(int32_t i=0; i<guys.Count(); i++)
34320 {
34321 if(guys.spr(i)->z > 0)
34322 {
34323 guys.spr(i)->y -= guys.spr(i)->z;
34324 guys.spr(i)->z = 0;
34325 }
34326
34327 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
34328 guys.spr(i)->yofs += 2;
34329 }
34330 }
34331
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 else if(wasSideview && !tmpscr_is_sideview)
34332 {
34333 for(int32_t i=0; i<guys.Count(); i++)
34334 {
34335 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
34336 guys.spr(i)->yofs -= 2;
34337 }
34338 }
34339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( warpType == wtEXIT )
34340 {
34341 //game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
34342 game->set_continue_scrn(scrID);
34343 game->set_continue_dmap(dmapID);
34344 lastentrance = scrID;
34345 //zprint("Setting Last Entrance to: %d\n", scrID);
34346 //zprint("lastentrance = %d\n",lastentrance);
34347 lastentrance_dmap = dmapID;
34348 //zprint("Setting Last Entrance DMap to: %d\n", dmapID);
34349 //zprint("lastentrance_dmap = %d\n",lastentrance_dmap);
34350 //lastentrance_dmap = currdmap;
34351 //lastentrance = game->get_continue_scrn();
34352 }
34353 else
34354 {
34355
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETENTRANCESCREEN) ) lastentrance = scrID;
34356
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETENTRANCEDMAP) ) lastentrance_dmap = dmapID;
34357
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETCONTINUESCREEN) ) game->set_continue_scrn(scrID);
34358
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETCONTINUEDMAP) ) game->set_continue_dmap(dmapID);
34359
34360
34361 }
34362
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tmpscr->flags4&fAUTOSAVE)
34363 {
34364 save_game(true,0);
34365 }
34366
34367
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tmpscr->flags6&fCONTINUEHERE)
34368 {
34369 lastentrance_dmap = currdmap;
34370 lastentrance = homescr;
34371 }
34372
34373 16 update_subscreens();
34374 16 verifyBothWeapons();
34375 32 Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
34376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
32 warpType==wtEXIT ? "Entrance/Exit" :
34377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 warpType==wtSCROLL ? "Scrolling Warp" :
34378 16 warpType==wtNOWARP ? "Cancel Warp" :
34379 "Insta-Warp");
34380
34381 16 eventlog_mapflags();
34382
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if (((warpFlags&warpFlagDONTRESTARTDMAPSCRIPT) != 0) == (get_qr(qr_SCRIPT_WARPS_DMAP_SCRIPT_TOGGLE) != 0)|| olddmap != currdmap) //Changed DMaps, or needs to reset the script
34383 {
34384 16 FFScript::deallocateAllScriptOwned(ScriptType::DMap, olddmap);
34385 16 initZScriptDMapScripts();
34386 16 }
34387 16 Hero.is_warping = false;
34388
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
34389 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
34390 16 return true;
34391 16 }
34392
34393 void FFScript::do_adjustvolume(const bool v)
34394 {
34395 if (get_qr(qr_OLD_SCRIPT_VOLUME))
34396 {
34397 int32_t perc = (SH::get_arg(sarg1, v) / 10000);
34398 float pct = perc / 100.0;
34399 // zprint("pct is: %f\n",pct);
34400 float temp_midi = 0;
34401 float temp_digi = 0;
34402 float temp_mus = 0;
34403 if (!(coreflags & FFCORE_SCRIPTED_MIDI_VOLUME))
34404 {
34405 // zprint("FFCORE_SCRIPTED_MIDI_VOLUME: wasn't set\n");
34406 temp_midi = do_getMIDI_volume();
34407 // zprint("temp_midi is %f\n", temp_midi);
34408 usr_midi_volume = do_getMIDI_volume();
34409 // zprint("usr_midi_volume stored as %d\n", usr_midi_volume);
34410 SetFFEngineFlag(FFCORE_SCRIPTED_MIDI_VOLUME, true);
34411 }
34412 else
34413 {
34414 temp_midi = (float)usr_midi_volume;
34415 }
34416 if (!(coreflags & FFCORE_SCRIPTED_DIGI_VOLUME))
34417 {
34418 temp_digi = do_getDIGI_volume();
34419 usr_digi_volume = do_getDIGI_volume();
34420 // zprint("usr_music_volume stored as %d\n", usr_digi_volume);
34421 SetFFEngineFlag(FFCORE_SCRIPTED_DIGI_VOLUME, true);
34422 }
34423 else
34424 {
34425 temp_digi = (float)usr_digi_volume;
34426 }
34427 if (!(coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME))
34428 {
34429 temp_mus = do_getMusic_volume();
34430 usr_music_volume = do_getMusic_volume();
34431 // zprint("usr_music_volume stored as %d\n", usr_music_volume);
34432 SetFFEngineFlag(FFCORE_SCRIPTED_MUSIC_VOLUME, true);
34433 }
34434 else
34435 {
34436 temp_mus = (float)usr_music_volume;
34437 }
34438
34439 temp_midi *= pct;
34440 temp_digi *= pct;
34441 temp_mus *= pct;
34442 // zprint("temp_midi is: %f\n",temp_midi);
34443 // zprint("temp_digi is: %f\n",temp_digi);
34444 // zprint("temp_mus is: %f\n",temp_mus);
34445 do_setMIDI_volume((int32_t)temp_midi);
34446 do_setDIGI_volume((int32_t)temp_digi);
34447 do_setMusic_volume((int32_t)temp_mus);
34448 }
34449 else
34450 {
34451 int32_t perc = SH::get_arg(sarg1, v);
34452 FFCore.usr_music_volume = vbound(perc, 0, 10000 * 100);
34453
34454 if (zcmusic != NULL)
34455 {
34456 if (zcmusic->playing != ZCM_STOPPED)
34457 {
34458 int32_t temp_volume = emusic_volume;
34459 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
34460 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
34461 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
34462 zcmusic_play(zcmusic, temp_volume);
34463 return;
34464 }
34465 }
34466 else if (currmidi > -1)
34467 {
34468 jukebox(currmidi);
34469 master_volume(digi_volume, midi_volume);
34470 }
34471 }
34472 }
34473
34474 void FFScript::do_adjustsfxvolume(const bool v)
34475 {
34476 if (get_qr(qr_OLD_SCRIPT_VOLUME))
34477 {
34478 int32_t perc = (SH::get_arg(sarg1, v) / 10000);
34479 float pct = perc / 100.0;
34480 float temp_sfx = 0;
34481 if (!(coreflags & FFCORE_SCRIPTED_SFX_VOLUME))
34482 {
34483 temp_sfx = do_getSFX_volume();
34484 usr_sfx_volume = (int32_t)temp_sfx;
34485 // zprint("usr_sfx_volume stored as %d\n", usr_sfx_volume);
34486 SetFFEngineFlag(FFCORE_SCRIPTED_SFX_VOLUME, true);
34487 }
34488 else
34489 {
34490 temp_sfx = (float)usr_sfx_volume;
34491 }
34492 temp_sfx *= pct;
34493 do_setSFX_volume((int32_t)temp_sfx);
34494 }
34495 else
34496 {
34497 int32_t perc = SH::get_arg(sarg1, v);
34498 FFCore.usr_sfx_volume = vbound(perc, 0, 10000 * 100);
34499 }
34500 }
34501
34502
34503 63813 void do_midi(bool v)
34504 {
34505 63813 int32_t MIDI = SH::get_arg(sarg1, v) / 10000;
34506
34507
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 63776 times.
63813 if(MIDI == 0)
34508 37 music_stop();
34509 else
34510 63776 jukebox(MIDI + (ZC_MIDI_COUNT - 1));
34511 63813 }
34512
34513
34514 void stop_sfx(const bool v)
34515 {
34516 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34517 int32_t sfx = (int32_t)ID;
34518 if(BC::checkSFXID(ID, "Game->EndSound") != SH::_NoError)
34519 return;
34520 stop_sfx(sfx);
34521 }
34522
34523 void pause_sfx(const bool v)
34524 {
34525 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34526 int32_t sfx = (int32_t)ID;
34527 if(BC::checkSFXID(ID, "Game->PauseSound") != SH::_NoError)
34528 return;
34529 pause_sfx(sfx);
34530 }
34531
34532 void resume_sfx(const bool v)
34533 {
34534 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34535 int32_t sfx = (int32_t)ID;
34536 if(BC::checkSFXID(ID, "Game->ResumeSound") != SH::_NoError)
34537 return;
34538 resume_sfx(sfx);
34539 }
34540
34541
34542
34543 79 void do_enh_music(bool v)
34544 {
34545 79 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
34546 79 int32_t track = (SH::get_arg(sarg2, v) / 10000)-1;
34547
34548
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(arrayptr == 0)
34549 music_stop();
34550 else // Pointer to a string..
34551 {
34552 79 string filename_str;
34553 char filename_char[256];
34554 bool ret;
34555
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 ArrayH::getString(arrayptr, filename_str, 256);
34556 79 strncpy(filename_char, filename_str.c_str(), 255);
34557 79 filename_char[255]='\0';
34558
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 ret=try_zcmusic(filename_char, track, -1000);
34559
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 set_register(sarg2, ret ? 10000 : 0);
34560 79 }
34561 79 }
34562
34563 void do_enh_music_crossfade()
34564 {
34565 int32_t arrayptr = SH::read_stack(ri->sp + 5) / 10000;
34566 int32_t track = SH::read_stack(ri->sp + 4) / 10000;
34567 int32_t fadeoutframes = zc_max(SH::read_stack(ri->sp + 3) / 10000, 0);
34568 int32_t fadeinframes = zc_max(SH::read_stack(ri->sp + 2) / 10000, 0);
34569 int32_t fademiddleframes = SH::read_stack(ri->sp + 1) / 10000;
34570 int32_t startpos = SH::read_stack(ri->sp);
34571
34572 if (arrayptr == 0)
34573 {
34574 bool ret = FFCore.play_enh_music_crossfade(NULL, track, fadeoutframes, fadeinframes, fademiddleframes, startpos);
34575 ri->d[rEXP1] = ret ? 10000 : 0;
34576 }
34577 else
34578 {
34579 string filename_str;
34580 char filename_char[256];
34581 ArrayH::getString(arrayptr, filename_str, 256);
34582 strncpy(filename_char, filename_str.c_str(), 255);
34583 filename_char[255] = '\0';
34584 bool ret = FFCore.play_enh_music_crossfade(filename_char, track, fadeoutframes, fadeinframes, fademiddleframes, startpos, true);
34585 ri->d[rEXP1] = ret ? 10000 : 0;
34586 }
34587 }
34588
34589 bool FFScript::play_enh_music_crossfade(char* name, int32_t track, int32_t fadeinframes, int32_t fadeoutframes, int32_t fademiddleframes, int32_t startpos, bool revertonfail)
34590 {
34591 double fadeoutpct = 1.0;
34592 // If there was an old fade going, use that as a multiplier for the new fade out
34593 if (zcmixer->newtrack != NULL)
34594 {
34595 fadeoutpct = double(zcmixer->newtrack->fadevolume) / 10000.0;
34596 }
34597
34598 ZCMUSIC* oldold = zcmixer->oldtrack;
34599 bool ret = false;
34600
34601 if (name == NULL)
34602 {
34603 // Pass currently playing music off to the mixer
34604 zcmixer->oldtrack = zcmusic;
34605 // Do not play new music
34606 zcmusic = NULL;
34607 zcmixer->newtrack = NULL;
34608
34609 zcmixer->fadeinframes = fadeinframes;
34610 zcmixer->fadeinmaxframes = fadeinframes;
34611 zcmixer->fadeoutframes = zc_max(fadeoutframes * fadeoutpct, 1);
34612 zcmixer->fadeoutmaxframes = fadeoutframes;
34613 if (fademiddleframes < 0)
34614 {
34615 zcmixer->fadeindelay = 0;
34616 zcmixer->fadeoutdelay = -fademiddleframes;
34617 }
34618 else
34619 {
34620 zcmixer->fadeindelay = fademiddleframes;
34621 zcmixer->fadeoutdelay = 0;
34622 }
34623 if (zcmixer->oldtrack != NULL)
34624 zcmixer->oldtrack->fadevolume = 10000;
34625 if (zcmixer->newtrack != NULL)
34626 zcmixer->newtrack->fadevolume = 0;
34627 }
34628 else // Pointer to a string..
34629 {
34630 // Pass currently playing music to the mixer
34631 zcmixer->oldtrack = zcmusic;
34632 zcmusic = NULL;
34633 zcmixer->newtrack = NULL;
34634
34635 ret = try_zcmusic(name, track, -1000, fadeoutframes);
34636 // If new music was found
34637 if (ret)
34638 {
34639 // New music fades in
34640 if (zcmusic != NULL)
34641 zcmusic->fadevolume = 0;
34642
34643 zcmixer->newtrack = zcmusic;
34644 zcmixer->fadeinframes = fadeinframes;
34645 zcmixer->fadeinmaxframes = fadeinframes;
34646 zcmixer->fadeoutframes = zc_max(fadeoutframes * fadeoutpct, 1);
34647 zcmixer->fadeoutmaxframes = fadeoutframes;
34648 if (fademiddleframes < 0)
34649 {
34650 zcmixer->fadeindelay = 0;
34651 zcmixer->fadeoutdelay = -fademiddleframes;
34652 }
34653 else
34654 {
34655 zcmixer->fadeindelay = fademiddleframes;
34656 zcmixer->fadeoutdelay = 0;
34657 }
34658 if (startpos > 0)
34659 zcmusic_set_curpos(zcmixer->newtrack, startpos);
34660 if (zcmixer->oldtrack != NULL)
34661 zcmixer->oldtrack->fadevolume = 10000;
34662 if (zcmixer->newtrack != NULL)
34663 zcmixer->newtrack->fadevolume = 0;
34664 }
34665 else if(revertonfail)
34666 {
34667 // Switch back to the old music
34668 zcmusic = zcmixer->oldtrack;
34669 zcmixer->newtrack = NULL;
34670 zcmixer->oldtrack = NULL;
34671 }
34672 }
34673
34674 // If there was already an old track playing, stop it
34675 if (oldold != NULL)
34676 {
34677 // Don't allow it to null both tracks if running twice in a row
34678 if (zcmixer->newtrack == NULL && zcmixer->oldtrack == NULL)
34679 {
34680 zcmixer->oldtrack = oldold;
34681
34682 if (oldold->fadeoutframes > 0)
34683 {
34684 zcmixer->fadeoutframes = zc_max(oldold->fadeoutframes * fadeoutpct, 1);
34685 zcmixer->fadeoutmaxframes = oldold->fadeoutframes;
34686 if (zcmixer->oldtrack != NULL)
34687 zcmixer->oldtrack->fadevolume = 10000;
34688 oldold->fadeoutframes = 0;
34689 }
34690 }
34691 else
34692 {
34693 zcmusic_stop(oldold);
34694 zcmusic_unload_file(oldold);
34695 oldold = NULL;
34696 }
34697 }
34698
34699 return ret;
34700 }
34701
34702 bool FFScript::doing_dmap_enh_music(int32_t dm)
34703 {
34704 if (DMaps[dm].tmusic[0] != 0)
34705 {
34706 if (zcmusic != NULL)
34707 {
34708 if (strcmp(zcmusic->filename, DMaps[dm].tmusic) == 0)
34709 {
34710 switch (zcmusic_get_type(zcmusic))
34711 {
34712 case ZCMF_OGG:
34713 case ZCMF_MP3:
34714 return true;
34715 case ZCMF_DUH:
34716 case ZCMF_GME:
34717 if (zcmusic->track == DMaps[dm].tmusictrack)
34718 {
34719 return true;
34720 }
34721 }
34722 }
34723 }
34724 }
34725 return false;
34726 }
34727
34728 17605 bool FFScript::can_dmap_change_music(int32_t dm)
34729 {
34730
1/4
✓ Branch 0 taken 17605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17605 switch (music_update_cond)
34731 {
34732 case MUSIC_UPDATE_SCREEN:
34733 17605 return true;
34734 case MUSIC_UPDATE_DMAP:
34735 return dm != -1 && dm != currdmap;
34736 case MUSIC_UPDATE_LEVEL:
34737 return dm != -1 && DMaps[dm].level != DMaps[currdmap].level;
34738 }
34739 return false;
34740 17605 }
34741
34742 void FFScript::do_set_music_position(const bool v)
34743 {
34744 int32_t newposition = SH::get_arg(sarg1, v);
34745
34746 set_zcmusicpos(newposition);
34747 }
34748
34749 void FFScript::do_get_music_position()
34750 {
34751 int32_t pos = replay_get_state(ReplayStateType::MusicPosition, [](){
34752 return zcmusic_get_curpos(zcmusic);
34753 });
34754 set_register(sarg1, pos);
34755 }
34756
34757 void FFScript::do_set_music_speed(const bool v)
34758 {
34759 int32_t newspeed = SH::get_arg(sarg1, v);
34760 set_zcmusicspeed(newspeed);
34761 }
34762
34763 void FFScript::do_get_music_length()
34764 {
34765 int32_t len = get_zcmusiclen();
34766 set_register(sarg1, len);
34767 }
34768
34769 void FFScript::do_set_music_loop()
34770 {
34771 double start = (get_register(sarg1) / 10000);
34772 double end = (get_register(sarg2) / 10000);
34773
34774 set_zcmusicloop(start, end);
34775 }
34776
34777 100 void do_get_enh_music_filename(const bool v)
34778 {
34779 100 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34780 100 int32_t arrayptr = get_register(sarg2) / 10000;
34781
34782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(BC::checkDMapID(ID, "Game->GetDMapMusicFilename") != SH::_NoError)
34783 return;
34784
34785
3/6
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
100 if(ArrayH::setArray(arrayptr, string(DMaps[ID].tmusic)) == SH::_Overflow)
34786 Z_scripterrlog("Array supplied to 'Game->GetDMapMusicFilename' not large enough\n");
34787 100 }
34788
34789 5 void do_get_enh_music_track(const bool v)
34790 {
34791 5 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34792
34793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(BC::checkDMapID(ID, "Game->GetDMapMusicTrack") != SH::_NoError)
34794 return;
34795
34796 5 set_register(sarg1, (DMaps[ID].tmusictrack+1)*10000);
34797 5 }
34798
34799 3750 void do_set_dmap_enh_music(const bool v)
34800 {
34801 3750 int32_t ID = SH::read_stack(ri->sp + 2) / 10000;
34802 3750 int32_t arrayptr = SH::read_stack(ri->sp + 1) / 10000;
34803 3750 int32_t track = (SH::read_stack(ri->sp + 0) / 10000)-1;
34804 3750 string filename_str;
34805
34806
2/4
✓ Branch 0 taken 3750 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3750 times.
✗ Branch 3 not taken.
3750 if(BC::checkDMapID(ID, "Game->SetDMapEnhancedMusic") != SH::_NoError)
34807 return;
34808
34809
1/2
✓ Branch 0 taken 3750 times.
✗ Branch 1 not taken.
3750 ArrayH::getString(arrayptr, filename_str, 56);
34810 3750 strncpy(DMaps[ID].tmusic, filename_str.c_str(), 55);
34811 3750 DMaps[ID].tmusic[55]='\0';
34812 3750 DMaps[ID].tmusictrack=track;
34813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3750 times.
3750 }
34814
34815
34816
34817
34818
34819
34820 ///----------------------------------------------------------------------------------------------------//
34821 //Array & string related
34822
34823 294114397 void do_arraysize()
34824 {
34825 294114397 int32_t arrayptr = get_register(sarg1) / 10000;
34826 294114397 ri->d[rEXP1] = ArrayH::getSize(arrayptr) * 10000;
34827 294114397 }
34828
34829 void do_tobyte()
34830 {
34831 int32_t b1 = get_register(sarg1) / 10000;
34832 byte b2 = b1;
34833 set_register(sarg1, b2 * 10000);
34834 }
34835
34836 void do_tosignedbyte()
34837 {
34838 int32_t b1 = get_register(sarg1) / 10000;
34839 signed char b2 = b1;
34840 set_register(sarg1, b2 * 10000);
34841 }
34842
34843 void do_tointeger()
34844 {
34845 int32_t b1 = get_register(sarg1) / 10000;
34846 set_register(sarg1, b1 * 10000);
34847 }
34848
34849 void do_floor()
34850 {
34851 double b1 = get_register(sarg1) / 10000.0;
34852 int32_t b2 = floor(b1);
34853 set_register(sarg1, b2 * 10000);
34854 }
34855
34856 void do_ceiling()
34857 {
34858 double b1 = get_register(sarg1) / 10000.0;
34859 int32_t b2 = ceil(b1);
34860 set_register(sarg1, b2 * 10000);
34861 }
34862
34863 void do_toword()
34864 {
34865 int32_t b1 = get_register(sarg1) / 10000;
34866 word b2 = b1;
34867 set_register(sarg1, b2 * 10000);
34868 }
34869
34870 void do_toshort()
34871 {
34872 int32_t b1 = get_register(sarg1) / 10000;
34873 int16_t b2 = b1;
34874 set_register(sarg1, b2 * 10000);
34875 }
34876
34877 10 void do_getsavename()
34878 {
34879 10 int32_t arrayptr = get_register(sarg1) / 10000;
34880
34881
3/6
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 if(ArrayH::setArray(arrayptr, string(game->get_name())) == SH::_Overflow)
34882 Z_scripterrlog("Array supplied to 'Game->GetSaveName' not large enough\n");
34883 10 }
34884
34885 void do_setsavename()
34886 {
34887 int32_t arrayptr = get_register(sarg1) / 10000;
34888
34889 string str;
34890 ArrayH::getString(arrayptr, str);
34891 byte j;
34892
34893 for(j = 0; str[j] != '\0'; j++)
34894 {
34895 if(j >= 8)
34896 {
34897 Z_scripterrlog("String supplied to 'Game->GetSaveName' too large\n");
34898 return;
34899 }
34900 }
34901
34902 game->set_name(str);
34903 }
34904
34905 3666 void do_getmessage(const bool v)
34906 {
34907 3666 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34908 3666 int32_t arrayptr = get_register(sarg2) / 10000;
34909
34910
1/2
✓ Branch 0 taken 3666 times.
✗ Branch 1 not taken.
3666 if(BC::checkMessage(ID, "Game->GetMessage") != SH::_NoError)
34911 return;
34912
34913
2/2
✓ Branch 0 taken 3618 times.
✓ Branch 1 taken 48 times.
3666 if(ArrayH::setArray(arrayptr, MsgStrings[ID].s) == SH::_Overflow)
34914 48 Z_scripterrlog("Array supplied to 'Game->GetMessage' not large enough\n");
34915 3666 }
34916
34917
34918
34919 void do_setmessage(const bool v)
34920 {
34921 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34922 int32_t arrayptr = get_register(sarg2) / 10000;
34923
34924 if(BC::checkMessage(ID, "Game->SetMessage") != SH::_NoError)
34925 return;
34926
34927 ArrayH::getString(arrayptr, MsgStrings[ID].s, MSG_NEW_SIZE);
34928 }
34929
34930
34931 void do_getdmapname(const bool v)
34932 {
34933 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34934 int32_t arrayptr = get_register(sarg2) / 10000;
34935
34936 if(BC::checkDMapID(ID, "Game->GetDMapName") != SH::_NoError)
34937 return;
34938
34939 if(ArrayH::setArray(arrayptr, string(DMaps[ID].name)) == SH::_Overflow)
34940 Z_scripterrlog("Array supplied to 'Game->GetDMapName' not large enough\n");
34941 }
34942
34943 void do_setdmapname(const bool v)
34944 {
34945 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34946 int32_t arrayptr = get_register(sarg2) / 10000;
34947
34948 string filename_str;
34949
34950 if(BC::checkDMapID(ID, "Game->Game->SetDMapName") != SH::_NoError)
34951 return;
34952
34953 ArrayH::getString(arrayptr, filename_str, 22);
34954 strncpy(DMaps[ID].name, filename_str.c_str(), 21);
34955 DMaps[ID].name[20]='\0';
34956 }
34957
34958 void do_getdmaptitle(const bool v)
34959 {
34960 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34961 int32_t arrayptr = get_register(sarg2) / 10000;
34962
34963 if(BC::checkDMapID(ID, "Game->GetDMapTitle") != SH::_NoError)
34964 return;
34965
34966 if (!get_qr(qr_OLD_DMAP_INTRO_STRINGS))
34967 {
34968 ArrayManager am(arrayptr);
34969 am.resize(DMaps[ID].title.size() + 1);
34970 }
34971 if(ArrayH::setArray(arrayptr, string(DMaps[ID].title)) == SH::_Overflow)
34972 Z_scripterrlog("Array supplied to 'Game->GetDMapTitle' not large enough\n");
34973 }
34974
34975
34976 void do_setdmaptitle(const bool v)
34977 {
34978 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34979 int32_t arrayptr = get_register(sarg2) / 10000;
34980 string filename_str;
34981
34982 if(BC::checkDMapID(ID, "Game->Game->SetDMapTitle") != SH::_NoError)
34983 return;
34984
34985 if (get_qr(qr_OLD_DMAP_INTRO_STRINGS))
34986 {
34987 char namestr[21];
34988 ArrayH::getString(arrayptr, filename_str, 21);
34989 strncpy(namestr, filename_str.c_str(), 20);
34990 namestr[20] = '\0';
34991 DMaps[ID].title.assign(namestr);
34992 }
34993 else
34994 {
34995 ArrayH::getString(arrayptr, filename_str, ArrayH::getSize(arrayptr));
34996 DMaps[ID].title = filename_str;
34997 }
34998 }
34999
35000 void do_getdmapintro(const bool v)
35001 {
35002 int32_t ID = SH::get_arg(sarg1, v) / 10000;
35003 int32_t arrayptr = get_register(sarg2) / 10000;
35004
35005 if(BC::checkDMapID(ID, "Game->GetDMapIntro") != SH::_NoError)
35006 return;
35007
35008 if(ArrayH::setArray(arrayptr, string(DMaps[ID].intro)) == SH::_Overflow)
35009 Z_scripterrlog("Array supplied to 'Game->GetDMapIntro' not large enough\n");
35010 }
35011
35012
35013 void do_setdmapintro(const bool v)
35014 {
35015 int32_t ID = SH::get_arg(sarg1, v) / 10000;
35016 int32_t arrayptr = get_register(sarg2) / 10000;
35017 string filename_str;
35018
35019 if(BC::checkDMapID(ID, "Game->Game->SetDMapIntro") != SH::_NoError)
35020 return;
35021
35022 ArrayH::getString(arrayptr, filename_str, 73);
35023 strncpy(DMaps[ID].intro, filename_str.c_str(), 72);
35024 DMaps[ID].intro[72]='\0';
35025 }
35026
35027 //Set npc and item names t.b.a. -Z
35028
35029 2567 void do_getitemname()
35030 {
35031 2567 int32_t arrayptr = get_register(sarg1) / 10000;
35032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2567 times.
2567 if(unsigned(ri->idata) >= MAXITEMS)
35033 {
35034 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
35035 return;
35036 }
35037
35038
3/6
✓ Branch 0 taken 2567 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2567 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2567 times.
✗ Branch 5 not taken.
2567 if(ArrayH::setArray(arrayptr, item_string[ri->idata]) == SH::_Overflow)
35039 Z_scripterrlog("Array supplied to 'itemdata->GetName' not large enough\n");
35040 2567 }
35041
35042 void do_getnpcname()
35043 {
35044 int32_t arrayptr = get_register(sarg1) / 10000;
35045
35046 if(GuyH::loadNPC(ri->guyref, "npc->GetName") != SH::_NoError)
35047 return;
35048
35049 word ID = (GuyH::getNPC()->id & 0xFFF);
35050
35051 if(ArrayH::setArray(arrayptr, guy_string[ID]) == SH::_Overflow)
35052 Z_scripterrlog("Array supplied to 'npc->GetName' not large enough\n");
35053 }
35054
35055 //npcdata->GetName
35056 void FFScript::do_getnpcdata_getname()
35057 {
35058 int32_t arrayptr = get_register(sarg1) / 10000;
35059 int32_t npc_id = ri->npcdataref;
35060 if((unsigned)npc_id > 511)
35061 {
35062 Z_scripterrlog("Invalid npc ID (%d) passed to npcdata->GetName().\n", npc_id);
35063 return;
35064 }
35065
35066 if(ArrayH::setArray(arrayptr, guy_string[npc_id]) == SH::_Overflow)
35067 Z_scripterrlog("Array supplied to 'npcdata->GetName()' not large enough\n");
35068 }
35069
35070 227724 void do_getffcscript()
35071 {
35072 227724 int32_t arrayptr = get_register(sarg1) / 10000;
35073 227724 string name;
35074 227724 int32_t num=-1;
35075
1/2
✓ Branch 0 taken 227724 times.
✗ Branch 1 not taken.
227724 ArrayH::getString(arrayptr, name, 256); // What's the limit on name length?
35076
35077
2/2
✓ Branch 0 taken 116286088 times.
✓ Branch 1 taken 227034 times.
116513122 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
35078 {
35079
3/4
✓ Branch 0 taken 116286088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116285398 times.
✓ Branch 3 taken 690 times.
116286088 if(strcmp(name.c_str(), ffcmap[i].scriptname.c_str())==0)
35080 {
35081 690 num=i+1;
35082 690 break;
35083 }
35084 116285398 }
35085
35086
1/2
✓ Branch 0 taken 227724 times.
✗ Branch 1 not taken.
227724 set_register(sarg1, num * 10000);
35087 227724 }
35088
35089 void do_npc_hero_in_range()
35090 {
35091 int32_t dist = get_register(sarg1) / 10000;
35092 if(GuyH::loadNPC(ri->guyref, "npc->LinedUp()") == SH::_NoError)
35093 {
35094 bool in_range = GuyH::getNPC()->HeroInRange(dist);
35095 set_register(sarg1, 0);
35096 }
35097 else set_register(sarg1, 0);
35098 }
35099
35100 80 void do_getitemscript()
35101 {
35102 80 int32_t arrayptr = get_register(sarg1) / 10000;
35103 80 string name;
35104 80 int32_t num=-1;
35105
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 ArrayH::getString(arrayptr, name, 256); // What's the limit on name length?
35106
35107
1/2
✓ Branch 0 taken 2360 times.
✗ Branch 1 not taken.
2360 for(int32_t i=0; i<512; i++)
35108 {
35109
3/4
✓ Branch 0 taken 2360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2280 times.
✓ Branch 3 taken 80 times.
2360 if(strcmp(name.c_str(), itemmap[i].scriptname.c_str())==0)
35110 {
35111 80 num=i+1;
35112 80 break;
35113 }
35114 2280 }
35115
35116
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 set_register(sarg1, num * 10000);
35117 80 }
35118
35119 ///----------------------------------------------------------------------------------------------------//
35120 //Tile Manipulation
35121
35122 16962076 void do_copytile(const bool v, const bool v2)
35123 {
35124 16962076 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35125 16962076 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
35126
35127 16962076 copy_tile(newtilebuf, tile, tile2, false);
35128 16962076 }
35129
35130 int32_t FFScript::IsBlankTile(int32_t i)
35131 {
35132 if( ((unsigned)i) > NEWMAXTILES )
35133 {
35134 Z_scripterrlog("Invalid tile ID (%d) passed to Graphics->IsBlankTile[]\n");
35135 return -1;
35136 }
35137
35138 byte *tilestart=newtilebuf[i].data;
35139 qword *di=(qword*)tilestart;
35140 int32_t parts=tilesize(newtilebuf[i].format)>>3;
35141
35142 for(int32_t j=0; j<parts; ++j, ++di)
35143 {
35144 if(*di!=0)
35145 {
35146 return 0;
35147 }
35148 }
35149
35150 return 1;
35151 }
35152
35153 int32_t FFScript::Is8BitTile(int32_t i)
35154 {
35155 if (((unsigned)i) > NEWMAXTILES)
35156 {
35157 Z_scripterrlog("Invalid tile ID (%d) passed to Graphics->Is8BitTile[]\n");
35158 return -1;
35159 }
35160
35161 return newtilebuf[i].format == tf8Bit ? 1 : 0;
35162 }
35163
35164 void do_swaptile(const bool v, const bool v2)
35165 {
35166 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35167 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
35168
35169 copy_tile(newtilebuf, tile, tile2, true);
35170 }
35171
35172 57032 void do_overlaytile(const bool v, const bool v2)
35173 {
35174 57032 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35175 57032 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
35176
35177
2/4
✓ Branch 0 taken 57032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57032 times.
✗ Branch 3 not taken.
57032 if(BC::checkTile(tile, "OverlayTile") != SH::_NoError ||
35178 57032 BC::checkTile(tile2, "OverlayTile") != SH::_NoError)
35179 return;
35180
35181 //Could add an arg for the CSet or something instead of just passing 0, currently only 8-bit is supported
35182 57032 overlay_tile(newtilebuf, tile, tile2, 0, false);
35183 57032 }
35184
35185 void do_fliprotatetile(const bool v, const bool v2)
35186 {
35187 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35188 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
35189
35190 if(BC::checkTile(tile, "FlipRotateTile") != SH::_NoError ||
35191 BC::checkTile(tile2, "FlipRotateTile") != SH::_NoError)
35192 return;
35193
35194 //fliprotatetile
35195 }
35196
35197 void do_settilepixel()
35198 {
35199 int32_t tile = SH::read_stack(ri->sp + 3) / 10000;
35200 int32_t x = SH::read_stack(ri->sp + 2) / 10000;
35201 int32_t y = SH::read_stack(ri->sp + 1) / 10000;
35202 int32_t val = SH::read_stack(ri->sp + 0) / 10000;
35203
35204 if(BC::checkTile(tile, "SetTilePixel") != SH::_NoError)
35205 return;
35206
35207 x = vbound(x, 0, 15);
35208 y = vbound(y, 0, 15);
35209 unpack_tile(newtilebuf, tile, 0, false);
35210 if (newtilebuf[tile].format == tf4Bit)
35211 val &= 0xF;
35212 unpackbuf[y * 16 + x] = val;
35213 pack_tile(newtilebuf, unpackbuf, tile);
35214 }
35215
35216 void do_gettilepixel()
35217 {
35218 int32_t tile = SH::read_stack(ri->sp + 3) / 10000;
35219 int32_t x = SH::read_stack(ri->sp + 2) / 10000;
35220 int32_t y = SH::read_stack(ri->sp + 1) / 10000;
35221 int32_t cs = SH::read_stack(ri->sp + 0) / 10000;
35222
35223 if(BC::checkTile(tile, "GetTilePixel") != SH::_NoError)
35224 return;
35225
35226 x = vbound(x, 0, 15);
35227 y = vbound(y, 0, 15);
35228 unpack_tile(newtilebuf, tile, 0, false);
35229 int32_t csoffs = newtilebuf[tile].format == tf8Bit ? 0 : cs * 16;
35230 ri->d[rEXP1] = 10000 * (unpackbuf[y * 16 + x] + csoffs);
35231 }
35232
35233 void do_shifttile(const bool v, const bool v2)
35234 {
35235 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35236 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
35237
35238 if(BC::checkTile(tile, "ShiftTile") != SH::_NoError ||
35239 BC::checkTile(tile2, "ShiftTile") != SH::_NoError)
35240 return;
35241
35242 //shifttile
35243 }
35244
35245 void do_cleartile(const bool v)
35246 {
35247 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35248
35249 if(BC::checkTile(tile, "ClearTile") != SH::_NoError)
35250 return;
35251
35252 reset_tile(newtilebuf, tile, newtilebuf[tile].format);
35253 }
35254
35255 2564 void do_combotile(const bool v)
35256 {
35257 2564 int32_t combo = SH::get_arg(sarg2, v) / 10000;
35258
35259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2564 times.
2564 if(BC::checkCombo(combo, "Game->ComboTile") != SH::_NoError)
35260 return;
35261
35262 2564 set_register(sarg1, combobuf[combo].tile * 10000);
35263 2564 }
35264
35265 94358266 void do_readpod(const bool v)
35266 {
35267 94358266 int32_t indx = SH::get_arg(sarg2, v) / 10000;
35268 94358266 int32_t val = ArrayH::getElement(ri->d[rINDEX] / 10000, indx, can_neg_array);
35269 94358266 set_register(sarg1, val);
35270 94358266 }
35271 63067586 void do_writepod(const bool v1, const bool v2)
35272 {
35273 63067586 int32_t indx = SH::get_arg(sarg1, v1) / 10000;
35274 63067586 int32_t val = SH::get_arg(sarg2, v2);
35275 63067586 ArrayH::setElement(ri->d[rINDEX] / 10000, indx, val, can_neg_array);
35276 63067586 }
35277 236286 void do_writepodstr()
35278 {
35279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236286 times.
236286 if(!sargstr) return;
35280 236286 auto ptr = get_register(sarg1) / 10000;
35281 236286 ArrayH::setArray(ptr, *sargstr);
35282 236286 }
35283 302 void do_writepodarr()
35284 {
35285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 302 times.
302 if(!sargvec) return;
35286 302 auto ptr = get_register(sarg1) / 10000;
35287 302 ArrayH::setArray(ptr, sargvec->size(), sargvec->data(), false);
35288 302 }
35289 int32_t get_object_arr(size_t sz)
35290 {
35291 if(sz > 214748) return 0;
35292 int32_t free_ptr = 1;
35293 auto it = objectRAM.begin();
35294 if(it != objectRAM.end())
35295 {
35296 if(it->first == 1)
35297 {
35298 for(free_ptr = 2; ; ++free_ptr)
35299 {
35300 if(objectRAM.find(free_ptr) == objectRAM.end())
35301 break;
35302 }
35303 }
35304 }
35305 ZScriptArray arr;
35306 arr.Resize(sz);
35307 arr.setValid(true);
35308 objectRAM[free_ptr] = arr;
35309 // auto res = objectRAM.emplace(free_ptr);
35310 // ZScriptArray& arr = res.first->second;
35311 // arr.Resize(sz);
35312
35313 return -free_ptr;
35314 }
35315 void destroy_object_arr(int32_t ptr)
35316 {
35317 if(ptr < 0)
35318 {
35319 auto it = objectRAM.find(-ptr);
35320 if(it != objectRAM.end())
35321 objectRAM.erase(it);
35322 }
35323 }
35324 void do_constructclass(ScriptType type, word script, int32_t i)
35325 {
35326 if(!sargvec) return;
35327
35328 size_t num_vars = sargvec->at(0);
35329 size_t total_vars = num_vars + sargvec->size()-1;
35330 auto destr_pc = ri->d[rEXP1];
35331 dword objref = FFCore.get_free_object(false);
35332
35333 if(user_object* obj = checkObject(objref, true))
35334 {
35335 obj->own(type, i);
35336 obj->owned_vars = num_vars;
35337 for(size_t q = 0; q < total_vars; ++q)
35338 {
35339 if(q < num_vars)
35340 {
35341 obj->data.push_back(0);
35342 }
35343 else
35344 {
35345 size_t sz = sargvec->at(q-num_vars+1);
35346 if(auto id = get_object_arr(sz))
35347 obj->data.push_back(10000*id);
35348 else obj->data.push_back(0); //nullptr
35349 }
35350 }
35351 set_register(sarg1, objref);
35352 ri->thiskey = objref;
35353 obj->prep(destr_pc,type,script,i);
35354 }
35355 else set_register(sarg1, 0);
35356 }
35357
35358 void do_readclass()
35359 {
35360 dword objref = get_register(sarg1);
35361 ri->d[rEXP1] = 0;
35362 int32_t ind = sarg2;
35363 if(user_object* obj = checkObject(objref))
35364 {
35365 if(unsigned(ind) >= obj->data.size())
35366 {
35367 Z_scripterrlog("Script tried to read position '%d' out of bounds on a '%d' size object (%d).", ind, obj->data.size(), objref);
35368 }
35369 else
35370 {
35371 ri->d[rEXP1] = obj->data.at(ind);
35372 }
35373 }
35374 }
35375 void do_writeclass()
35376 {
35377 dword objref = get_register(sarg1);
35378 int32_t ind = sarg2;
35379 if(user_object* obj = checkObject(objref))
35380 {
35381 if(unsigned(ind) >= obj->data.size())
35382 {
35383 Z_scripterrlog("Script tried to write position '%d' out of bounds on a '%d' size object (%d).", ind, obj->data.size(), objref);
35384 }
35385 else
35386 {
35387 obj->data[ind] = ri->d[rEXP1];
35388 }
35389 }
35390 }
35391 void do_freeclass()
35392 {
35393 dword objref = get_register(sarg1);
35394 if(user_object* obj = checkObject(objref, true))
35395 {
35396 obj->clear();
35397 }
35398 ri->d[rEXP1] = 0;
35399 }
35400
35401 bool zasm_advance()
35402 {
35403 if( key[KEY_INSERT] )
35404 {
35405 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
35406 {
35407 if(CHECK_CTRL_CMD)
35408 {
35409 FFCore.zasm_break_mode = ZASM_BREAK_SKIP_SCRIPT;
35410 }
35411 else FFCore.zasm_break_mode = ZASM_BREAK_ADVANCE_SCRIPT;
35412 }
35413 else if(key[KEY_ALT] || key[KEY_ALTGR])
35414 {
35415 if(CHECK_CTRL_CMD)
35416 {
35417 FFCore.zasm_break_mode = ZASM_BREAK_SKIP;
35418 }
35419 else FFCore.zasm_break_mode = ZASM_BREAK_NONE;
35420 }
35421 else if(CHECK_CTRL_CMD)
35422 {
35423 FFCore.ZASMPrint(false); //Close debugger
35424 FFCore.zasm_break_mode = ZASM_BREAK_NONE;
35425 }
35426 return true;
35427 }
35428 if(!zasm_debugger)
35429 {
35430 FFCore.zasm_break_mode = ZASM_BREAK_NONE;
35431 return true;
35432 }
35433 return false;
35434 }
35435
35436 int32_t get_own_i(ScriptType type)
35437 {
35438 switch(type)
35439 {
35440 case ScriptType::Lwpn:
35441 return ri->lwpn;
35442 case ScriptType::Ewpn:
35443 return ri->ewpn;
35444 case ScriptType::ItemSprite:
35445 return ri->itemref;
35446 case ScriptType::NPC:
35447 return ri->guyref;
35448 case ScriptType::FFC:
35449 return ri->ffcref;
35450 }
35451 return 0;
35452 }
35453
35454 portal* loadportal(savedportal& p);
35455 ///----------------------------------------------------------------------------------------------------//
35456 // Run the script //
35457 ///----------------------------------------------------------------------------------------------------//
35458
35459
35460 10302848 int32_t run_script(ScriptType type, const word script, const int32_t i)
35461 {
35462
2/4
✓ Branch 0 taken 10302848 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10302848 times.
10302848 if(Quit==qRESET || Quit==qEXIT) // In case an earlier script hung
35463 return RUNSCRIPT_ERROR;
35464
35465
4/4
✓ Branch 0 taken 6413590 times.
✓ Branch 1 taken 3889258 times.
✓ Branch 2 taken 642464 times.
✓ Branch 3 taken 5771126 times.
10302848 if(type != ScriptType::Global && !script) return RUNSCRIPT_OK; //Safeguard against running null scripts
35466
35467 9660384 combopos_modified = -1;
35468 9660384 curScriptType=type;
35469 9660384 curScriptNum=script;
35470 9660384 curScriptIndex=i;
35471 //numInstructions=0; //DON'T CLEAR THIS OR IT CAN HARDLOCK! -Em
35472
35473
2/4
✓ Branch 0 taken 9660384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9660384 times.
9660384 if (!(type >= ScriptType::First && type <= ScriptType::Last))
35474 {
35475 al_trace("Invalid script type: %d\n", (int)type);
35476 return RUNSCRIPT_ERROR;
35477 }
35478
35479 9660384 bool got_initialized = false;
35480
6/8
✓ Branch 0 taken 8919206 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 188480 times.
✓ Branch 4 taken 104554 times.
✓ Branch 5 taken 2517 times.
✓ Branch 6 taken 444085 times.
✓ Branch 7 taken 1542 times.
9660384 switch(type)
35481 {
35482 case ScriptType::FFC:
35483 case ScriptType::Global:
35484 case ScriptType::Player:
35485 case ScriptType::DMap:
35486 case ScriptType::OnMap:
35487 case ScriptType::ScriptedActiveSubscreen:
35488 case ScriptType::ScriptedPassiveSubscreen:
35489 case ScriptType::EngineSubscreen:
35490 case ScriptType::Screen:
35491 case ScriptType::Combo:
35492 case ScriptType::Item:
35493 {
35494 // TODO: finish refactoring the other script types.
35495 8919206 got_initialized = set_current_script_engine_data(type, script, i);
35496 }
35497 8919206 break;
35498
35499 case ScriptType::NPC:
35500 {
35501 int32_t npc_index = GuyH::getNPCIndex(i);
35502 enemy *w = (enemy*)guys.spr(npc_index);
35503 ri = &(w->scrmem->scriptData);
35504 curscript = guyscripts[w->script];
35505 stack = &(w->scrmem->stack);
35506 ri->guyref = i;
35507
35508 if (!w->initialised)
35509 {
35510 got_initialized = true;
35511 for ( int32_t q = 0; q < 8; q++ )
35512 {
35513 ri->d[q] = w->initD[q];
35514 }
35515 w->initialised = 1;
35516 }
35517 }
35518 break;
35519
35520 case ScriptType::Lwpn:
35521 {
35522 188480 int32_t lwpn_index = LwpnH::getLWeaponIndex(i);
35523 188480 weapon *w = (weapon*)Lwpns.spr(lwpn_index);
35524 188480 ri = &(w->scrmem->scriptData);
35525 188480 curscript = lwpnscripts[w->weaponscript];
35526 188480 stack = &(w->scrmem->stack);
35527 188480 ri->lwpn = i;
35528
35529
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 61248 times.
188480 if (!w->initialised)
35530 {
35531 61248 got_initialized = true;
35532
2/2
✓ Branch 0 taken 489984 times.
✓ Branch 1 taken 61248 times.
551232 for ( int32_t q = 0; q < 8; q++ )
35533 {
35534 489984 ri->d[q] = w->weap_initd[q]; //w->initiald[q];
35535 489984 }
35536 61248 w->initialised = 1;
35537 61248 }
35538 }
35539 188480 break;
35540
35541 case ScriptType::Ewpn:
35542 {
35543 104554 int32_t ewpn_index = EwpnH::getEWeaponIndex(i);
35544 104554 weapon *w = (weapon*)Ewpns.spr(ewpn_index);
35545 104554 ri = &(w->scrmem->scriptData);
35546 104554 curscript = ewpnscripts[w->weaponscript];
35547 104554 stack = &(w->scrmem->stack);
35548 104554 ri->ewpn = i;
35549
35550
2/2
✓ Branch 0 taken 103279 times.
✓ Branch 1 taken 1275 times.
104554 if (!w->initialised)
35551 {
35552 1275 got_initialized = true;
35553
2/2
✓ Branch 0 taken 10200 times.
✓ Branch 1 taken 1275 times.
11475 for ( int32_t q = 0; q < 8; q++ )
35554 {
35555 10200 ri->d[q] = w->weap_initd[q];
35556 10200 }
35557 1275 w->initialised = 1;
35558 1275 }
35559 }
35560 104554 break;
35561
35562 case ScriptType::ItemSprite:
35563 {
35564 2517 int32_t the_index = ItemH::getItemIndex(i);
35565 2517 item *w = (item*)items.spr(the_index);
35566 2517 ri = &(w->scrmem->scriptData);
35567 2517 curscript = itemspritescripts[w->script];
35568 2517 stack = &(w->scrmem->stack);
35569 2517 ri->itemref = i;
35570
35571
2/2
✓ Branch 0 taken 2435 times.
✓ Branch 1 taken 82 times.
2517 if (!w->initialised)
35572 {
35573 82 got_initialized = true;
35574
2/2
✓ Branch 0 taken 656 times.
✓ Branch 1 taken 82 times.
738 for ( int32_t q = 0; q < 8; q++ )
35575 {
35576 656 ri->d[q] = w->initD[q];
35577 656 }
35578 82 w->initialised = 1;
35579 82 }
35580 }
35581 2517 break;
35582
35583 case ScriptType::Generic:
35584 {
35585 444085 user_genscript& scr = user_scripts[script];
35586 444085 stack = &scr.stack;
35587 444085 ri = &scr.ri;
35588 444085 ri->genericdataref = script;
35589 444085 curscript = genericscripts[script];
35590 444085 scr.waitevent = false;
35591
2/2
✓ Branch 0 taken 443736 times.
✓ Branch 1 taken 349 times.
444085 if(!scr.initialized)
35592 {
35593 349 got_initialized = true;
35594 349 scr.initialized = true;
35595
2/2
✓ Branch 0 taken 2792 times.
✓ Branch 1 taken 349 times.
3141 for (int q = 0; q < 8; ++q)
35596 2792 ri->d[q] = scr.initd[q];
35597 349 }
35598 }
35599 444085 break;
35600
35601 case ScriptType::GenericFrozen:
35602 {
35603 1542 ri = genericActiveData.back();
35604 1542 ri->genericdataref = script;
35605 1542 curscript = genericscripts[script];
35606 1542 stack = generic_active_stack.back();
35607
2/2
✓ Branch 0 taken 1532 times.
✓ Branch 1 taken 10 times.
1542 if(!gen_active_initialized)
35608 {
35609 10 got_initialized = true;
35610 10 gen_active_initialized = true;
35611
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 10 times.
90 for (int q = 0; q < 8; ++q)
35612 80 ri->d[q] = user_scripts[script].initd[q];
35613 10 }
35614 }
35615 1542 break;
35616
35617 default:
35618 {
35619 al_trace("No other scripts are currently supported\n");
35620 return RUNSCRIPT_ERROR;
35621 }
35622 }
35623
35624 // Because qst.cpp likes to write script_data without setting this.
35625 9660384 curscript->meta.script_type = type;
35626
35627 // No need to do anything if the script is not valid.
35628 // An example of this is found in `playground.qst` player scripts, which have scripts with
35629 // a single 0xFFFF command.
35630 // Can't actually do this because we must unset `doscript` via the `scommand == 0xFFFF` handling in run_script_int.
35631 // Otherwise can get freeze, like in ending.cpp
35632 // if (!curscript->valid())
35633 // return RUNSCRIPT_OK;
35634
35635 9660384 script_funcrun = false;
35636
35637
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9660384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9660384 if (DEBUG_PRINT_ZASM && !seen_scripts.contains(curscript->id))
35638 {
35639 seen_scripts.insert(curscript->id);
35640 ScriptDebugHandle h(ScriptDebugHandle::OutputSplit::ByScript, curscript);
35641 h.print_zasm(curScriptNum, curScriptIndex);
35642 }
35643
35644 9660384 JittedScriptHandle* jitted_script = nullptr;
35645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9660384 times.
9660384 if (jit_is_enabled())
35646 {
35647 9660384 auto it = jitted_scripts.find({curscript, ri});
35648
2/2
✓ Branch 0 taken 11012 times.
✓ Branch 1 taken 9649372 times.
9660384 if (it == jitted_scripts.end())
35649 {
35650 11012 jitted_scripts[{curscript, ri}] = jitted_script = jit_create_script_handle(curscript, ri);
35651 11012 }
35652 else
35653 {
35654 9649372 jitted_script = it->second;
35655 }
35656 9660384 }
35657
35658 9660384 runtime_script_debug_handle = nullptr;
35659
1/2
✓ Branch 0 taken 9660384 times.
✗ Branch 1 not taken.
9660384 if (script_debug_is_runtime_debugging())
35660 {
35661 if (!script_debug_handles.contains(curscript->id))
35662 {
35663 script_debug_handles.emplace(curscript->id, ScriptDebugHandle(ScriptDebugHandle::OutputSplit::ByFrame, curscript));
35664 }
35665 runtime_script_debug_handle = &script_debug_handles.at(curscript->id);
35666 runtime_script_debug_handle->update_file();
35667 runtime_script_debug_handle->print(fmt::format("\n=== running script type: {} index: {} name: {} i: {} script: {}\n", ScriptTypeToString(curscript->id.type), curscript->id.index, curscript->meta.script_name, i, script).c_str());
35668 }
35669
1/2
✓ Branch 0 taken 9660384 times.
✗ Branch 1 not taken.
9660384 if (script_debug_is_runtime_debugging() == 1)
35670 {
35671 runtime_script_debug_handle->print(script_debug_registers_and_stack_to_string().c_str());
35672 runtime_script_debug_handle->print("\n");
35673 }
35674
35675 int32_t result;
35676
2/2
✓ Branch 0 taken 9659389 times.
✓ Branch 1 taken 995 times.
9660384 if (jitted_script)
35677 {
35678
2/2
✓ Branch 0 taken 9579313 times.
✓ Branch 1 taken 80076 times.
9659389 if (got_initialized)
35679 80076 jit_reinit(jitted_script);
35680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9659389 times.
9659389 if (ri->waitframes)
35681 {
35682 --ri->waitframes;
35683 result = RUNSCRIPT_OK;
35684 }
35685 else
35686 {
35687 9659389 result = jit_run_script(jitted_script);
35688 }
35689 9659389 }
35690 else
35691 {
35692 995 result = run_script_int(false);
35693 }
35694
35695
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 9660384 times.
✓ Branch 2 taken 9660384 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9660384 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9660384 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 9660384 times.
✓ Branch 10 taken 9660384 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
19320768 if (replay_is_active() && replay_get_meta_bool("debug_script_state"))
35696 {
35697 std::string str = script_debug_registers_and_stack_to_string();
35698 util::replstr(str, "\n", " ");
35699 replay_step_comment(str);
35700 }
35701
35702 #ifdef _SCRIPT_COUNTER
35703 if (replay_get_frame() > 10000-50)
35704 {
35705 al_trace("\nPrinting ZASM timings:\n\n");
35706
35707 std::vector<std::pair<int, int>> timing_results;
35708 for (int j = 0; j < NUMCOMMANDS; j++)
35709 {
35710 if (script_execount[j])
35711 {
35712 int32_t ms = script_timer[j] / 1000000.0;
35713 timing_results.push_back({j, ms});
35714 }
35715 }
35716 std::sort(timing_results.begin(), timing_results.end(), [](auto &left, auto &right) {
35717 return left.second > right.second;
35718 });
35719 for (auto &it : timing_results)
35720 {
35721 al_trace("Command %s took %d ms complete in %ld executions.\n",
35722 script_debug_command_to_string(it.first).c_str(), it.second, script_execount[it.first]);
35723 }
35724 }
35725 #endif
35726
35727
1/2
✓ Branch 0 taken 9660384 times.
✗ Branch 1 not taken.
9660384 if (runtime_script_debug_handle)
35728 runtime_script_debug_handle->print(fmt::format("result: {}\n", result).c_str());
35729 9660384 return result;
35730 10302848 }
35731
35732 712307661 int32_t run_script_int(bool is_jitted)
35733 {
35734 712307661 ScriptType type = curScriptType;
35735 712307661 word script = curScriptNum;
35736 712307661 int32_t i = curScriptIndex;
35737
35738 712307661 int commands_run = 0;
35739
2/2
✓ Branch 0 taken 712306666 times.
✓ Branch 1 taken 995 times.
712307661 if (is_jitted) goto j_command;
35740
35741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 995 times.
995 if(ri->waitframes)
35742 {
35743 --ri->waitframes;
35744 return RUNSCRIPT_OK;
35745 }
35746 995 zs_vargs.clear();
35747
35748 #ifdef _FFDISSASSEMBLY
35749
35750 if(curscript->zasm[ri->pc].command != 0xFFFF)
35751 {
35752 #ifdef _FFONESCRIPTDISSASSEMBLY
35753 zc_trace_clear();
35754 #endif
35755
35756 switch(type)
35757 {
35758 case ScriptType::FFC:
35759 al_trace("\nStart of FFC script %i processing on FFC %i:\n", script, i);
35760 break;
35761
35762 case ScriptType::Item:
35763 al_trace("\nStart of item script %i processing:\n", script);
35764 break;
35765
35766 case ScriptType::Global:
35767 al_trace("\nStart of global script %I processing:\n", script);
35768 break;
35769 }
35770 }
35771
35772 #endif
35773
35774
2/4
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 995 times.
1990 if( FFCore.zasm_break_mode == ZASM_BREAK_ADVANCE_SCRIPT || FFCore.zasm_break_mode == ZASM_BREAK_SKIP_SCRIPT )
35775 {
35776 if( zasm_debugger )
35777 {
35778 //Halt on new script if set to advance to next script
35779 FFCore.zasm_break_mode = ZASM_BREAK_HALT;
35780 FFCore.TraceScriptIDs(true);
35781 coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
35782 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),"Breaking for script start\n");
35783 }
35784 else FFCore.zasm_break_mode = ZASM_BREAK_NONE;
35785 }
35786
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 995 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
995 else if( zasm_debugger && !(SKIPZASMPRINT()))
35787 {
35788 //Print new script metadata when starting script
35789 FFCore.TraceScriptIDs(true);
35790 coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
35791 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),"Start of script\n");
35792 }
35793
35794 j_command:
35795 712307661 bool is_debugging = script_debug_is_runtime_debugging() == 2;
35796 712307661 bool increment = true;
35797 712307661 word scommand = curscript->zasm[ri->pc].command;
35798 712307661 bool hit_invalid_zasm = false;
35799 712307661 bool no_dealloc = false;
35800
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 715400428 times.
715401436 while(scommand != 0xFFFF)
35801 {
35802 #ifdef _SCRIPT_COUNTER
35803 std::chrono::steady_clock::time_point start_time, end_time;
35804 start_time = std::chrono::steady_clock::now();
35805 #endif
35806
35807 715400428 scommand = curscript->zasm[ri->pc].command;
35808 715400428 sarg1 = curscript->zasm[ri->pc].arg1;
35809 715400428 sarg2 = curscript->zasm[ri->pc].arg2;
35810 715400428 sargstr = curscript->zasm[ri->pc].strptr;
35811 715400428 sargvec = curscript->zasm[ri->pc].vecptr;
35812 //zprint2("Executing zasm: %d,%d,%d,%d,%d\n",scommand,sarg1,sarg2,get_register(sarg1),get_register(sarg2));
35813
35814
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 715400428 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
715400428 if (is_debugging && (!is_jitted || commands_run > 0))
35815 {
35816 runtime_script_debug_handle->pre_command();
35817 }
35818
35819 715400428 bool waiting = true;
35820
4/6
✓ Branch 0 taken 705810520 times.
✓ Branch 1 taken 1864765 times.
✓ Branch 2 taken 177522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7547621 times.
✗ Branch 5 not taken.
715400428 switch(scommand) //Handle waitframe-type commands first
35821 {
35822 case WAITDRAW:
35823 {
35824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1864765 times.
1864765 if(script_funcrun)
35825 scommand = NOP;
35826
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1864765 times.
✗ Branch 2 not taken.
1864765 else switch(type)
35827 {
35828 case ScriptType::EngineSubscreen: //ignore waitdraws
35829 Z_scripterrlog("'Waitdraw()' is invalid in subscreen scripts, will be ignored\n");
35830 scommand = NOP;
35831 break;
35832 case ScriptType::Generic:
35833 case ScriptType::GenericFrozen: //ignore waitdraws
35834 Z_scripterrlog("'Waitdraw()' is invalid in generic scripts, will be ignored\n");
35835 scommand = NOP;
35836 break;
35837 }
35838 1864765 break;
35839 }
35840 case WAITTO:
35841 {
35842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177522 times.
177522 if(script_funcrun)
35843 scommand = NOP;
35844
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 177522 times.
177522 else switch(type)
35845 {
35846 case ScriptType::GenericFrozen:
35847 //ignore, no warn/error
35848 scommand = NOP;
35849 break;
35850 case ScriptType::Generic:
35851 {
35852 177522 user_genscript& scr = user_scripts[script];
35853 177522 int32_t target = get_register(sarg1)/10000L;
35854 177522 bool atleast = get_register(sarg2)!=0;
35855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177522 times.
177522 if(unsigned(target) > SCR_TIMING_END_FRAME)
35856 {
35857 Z_scripterrlog("Invalid value '%d' provided to 'WaitTo()'\n", target);
35858 scommand = NOP;
35859 break;
35860 }
35861
1/4
✓ Branch 0 taken 177522 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177522 if(genscript_timing == target ||
35862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177522 times.
177522 (atleast && genscript_timing < target))
35863 {
35864 //Already that time, skip the command
35865 scommand = NOP;
35866 break;
35867 }
35868 177522 scr.waituntil = scr_timing(target);
35869 177522 scr.wait_atleast = atleast;
35870 177522 break;
35871 }
35872 default:
35873 Z_scripterrlog("'WaitTo()' is only valid in 'generic' scripts!\n");
35874 scommand = NOP;
35875 break;
35876 }
35877 177522 break;
35878 }
35879 case WAITEVENT:
35880 {
35881 if(script_funcrun)
35882 scommand = NOP;
35883 else switch(type)
35884 {
35885 case ScriptType::GenericFrozen:
35886 scommand = WAITFRAME;
35887 ri->d[0] = GENSCR_EVENT_NIL*10000; //no event
35888 break;
35889 case ScriptType::Generic:
35890 {
35891 user_genscript& scr = user_scripts[script];
35892 scr.waitevent = true;
35893 break;
35894 }
35895 default:
35896 Z_scripterrlog("'WaitEvent()' is only valid in 'generic' scripts!\n");
35897 scommand = NOP;
35898 break;
35899 }
35900 break;
35901 }
35902 case WAITFRAME:
35903 {
35904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547621 times.
7547621 if(script_funcrun)
35905 scommand = NOP;
35906
2/2
✓ Branch 0 taken 7281058 times.
✓ Branch 1 taken 266563 times.
7547621 else switch(type)
35907 {
35908 case ScriptType::Generic:
35909 266563 user_scripts[script].waituntil = SCR_TIMING_START_FRAME;
35910 266563 user_scripts[script].wait_atleast = false;
35911 266563 break;
35912 }
35913 7547621 break;
35914 }
35915 case WAITFRAMESR:
35916 {
35917 auto count = get_register(sarg1);
35918 if(script_funcrun || count <= 0)
35919 {
35920 scommand = NOP;
35921 break;
35922 }
35923 auto frames = count/10000;
35924 if(count%10000) ++frames; //round up decimals
35925 ri->waitframes = frames-1; //this frame doesn't count
35926 switch(type)
35927 {
35928 case ScriptType::Generic:
35929 user_scripts[script].waituntil = SCR_TIMING_START_FRAME;
35930 user_scripts[script].wait_atleast = false;
35931 break;
35932 }
35933 break;
35934 }
35935 705810520 default: waiting = false;
35936 705810520 }
35937
3/4
✓ Branch 0 taken 9589908 times.
✓ Branch 1 taken 705810520 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9589908 times.
715400428 if(waiting && scommand != NOP)
35938 9589908 break;
35939
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 705810520 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
705810520 if(waiting && is_jitted)
35940 break;
35941
35942 705810520 numInstructions++;
35943
2/2
✓ Branch 0 taken 705104737 times.
✓ Branch 1 taken 705783 times.
705810520 if(numInstructions==hangcount) // No need to check frequently
35944 {
35945 705783 numInstructions=0;
35946 705783 poll_keyboard();
35947 705783 checkQuitKeys();
35948
1/2
✓ Branch 0 taken 705783 times.
✗ Branch 1 not taken.
705783 if(Quit)
35949 scommand=0xFFFF;
35950 705783 }
35951
35952 //Handle manual breaking
35953
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 705810520 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
705810520 if( zasm_debugger && zc_readrawkey(KEY_INSERT, true))
35954 FFCore.zasm_break_mode = ZASM_BREAK_HALT;
35955 //Break
35956
1/2
✓ Branch 0 taken 705810520 times.
✗ Branch 1 not taken.
705810520 while( FFCore.zasm_break_mode == ZASM_BREAK_HALT )
35957 {
35958 poll_keyboard();
35959 if(zasm_advance()) break;
35960 checkQuitKeys();
35961 if(Quit)
35962 {
35963 scommand=0xFFFF;
35964 break;
35965 }
35966 }
35967
35968
1/2
✓ Branch 0 taken 705810520 times.
✗ Branch 1 not taken.
705810520 if ( zasm_debugger ) FFCore.ZASMPrintCommand(scommand);
35969
138/929
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2928911 times.
✓ Branch 4 taken 302 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 6983690 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 708 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 252 times.
✓ Branch 27 taken 6164970 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 13724 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 1 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 93 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✓ Branch 43 taken 68 times.
✓ Branch 44 taken 102 times.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✓ Branch 47 taken 17 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 34296 times.
✓ Branch 50 taken 3553 times.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✓ Branch 54 taken 2 times.
✓ Branch 55 taken 287 times.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✓ Branch 60 taken 126 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 5580 times.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✓ Branch 66 taken 63813 times.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✓ Branch 72 taken 173 times.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✓ Branch 75 taken 136832 times.
✓ Branch 76 taken 25412 times.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✓ Branch 82 taken 756866 times.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✓ Branch 92 taken 27033 times.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✓ Branch 95 taken 132144 times.
✗ Branch 96 not taken.
✓ Branch 97 taken 249 times.
✓ Branch 98 taken 16038753 times.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✓ Branch 107 taken 57032 times.
✗ Branch 108 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 114 not taken.
✗ Branch 115 not taken.
✗ Branch 116 not taken.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✗ Branch 123 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✗ Branch 127 not taken.
✗ Branch 128 not taken.
✗ Branch 129 not taken.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✗ Branch 138 not taken.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 144 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✗ Branch 148 not taken.
✗ Branch 149 not taken.
✗ Branch 150 not taken.
✗ Branch 151 not taken.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✗ Branch 156 not taken.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✗ Branch 162 not taken.
✗ Branch 163 not taken.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✗ Branch 167 not taken.
✗ Branch 168 not taken.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✗ Branch 171 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✗ Branch 174 not taken.
✗ Branch 175 not taken.
✗ Branch 176 not taken.
✗ Branch 177 not taken.
✗ Branch 178 not taken.
✗ Branch 179 not taken.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 183 not taken.
✗ Branch 184 not taken.
✗ Branch 185 not taken.
✗ Branch 186 not taken.
✗ Branch 187 not taken.
✗ Branch 188 not taken.
✗ Branch 189 not taken.
✗ Branch 190 not taken.
✗ Branch 191 not taken.
✗ Branch 192 not taken.
✓ Branch 193 taken 1 times.
✓ Branch 194 taken 1 times.
✗ Branch 195 not taken.
✗ Branch 196 not taken.
✗ Branch 197 not taken.
✗ Branch 198 not taken.
✓ Branch 199 taken 1 times.
✗ Branch 200 not taken.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✗ Branch 207 not taken.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✗ Branch 210 not taken.
✗ Branch 211 not taken.
✗ Branch 212 not taken.
✓ Branch 213 taken 576754 times.
✓ Branch 214 taken 37306789 times.
✗ Branch 215 not taken.
✗ Branch 216 not taken.
✗ Branch 217 not taken.
✗ Branch 218 not taken.
✗ Branch 219 not taken.
✓ Branch 220 taken 69460 times.
✗ Branch 221 not taken.
✗ Branch 222 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✗ Branch 233 not taken.
✗ Branch 234 not taken.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✓ Branch 237 taken 62479687 times.
✓ Branch 238 taken 31878579 times.
✓ Branch 239 taken 38051438 times.
✓ Branch 240 taken 22087237 times.
✓ Branch 241 taken 236286 times.
✗ Branch 242 not taken.
✗ Branch 243 not taken.
✗ Branch 244 not taken.
✗ Branch 245 not taken.
✗ Branch 246 not taken.
✗ Branch 247 not taken.
✗ Branch 248 not taken.
✗ Branch 249 not taken.
✗ Branch 250 not taken.
✗ Branch 251 not taken.
✗ Branch 252 not taken.
✗ Branch 253 not taken.
✓ Branch 254 taken 72811 times.
✗ Branch 255 not taken.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✗ Branch 258 not taken.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✗ Branch 261 not taken.
✓ Branch 262 taken 302 times.
✗ Branch 263 not taken.
✓ Branch 264 taken 7008212 times.
✗ Branch 265 not taken.
✗ Branch 266 not taken.
✗ Branch 267 not taken.
✗ Branch 268 not taken.
✓ Branch 269 taken 294114397 times.
✗ Branch 270 not taken.
✗ Branch 271 not taken.
✗ Branch 272 not taken.
✓ Branch 273 taken 227724 times.
✓ Branch 274 taken 80 times.
✗ Branch 275 not taken.
✗ Branch 276 not taken.
✗ Branch 277 not taken.
✗ Branch 278 not taken.
✗ Branch 279 not taken.
✗ Branch 280 not taken.
✗ Branch 281 not taken.
✗ Branch 282 not taken.
✗ Branch 283 not taken.
✗ Branch 284 not taken.
✓ Branch 285 taken 3205819 times.
✓ Branch 286 taken 76 times.
✓ Branch 287 taken 1263 times.
✓ Branch 288 taken 60936 times.
✗ Branch 289 not taken.
✓ Branch 290 taken 14918 times.
✗ Branch 291 not taken.
✓ Branch 292 taken 864999 times.
✗ Branch 293 not taken.
✓ Branch 294 taken 15144 times.
✗ Branch 295 not taken.
✗ Branch 296 not taken.
✗ Branch 297 not taken.
✗ Branch 298 not taken.
✗ Branch 299 not taken.
✗ Branch 300 not taken.
✗ Branch 301 not taken.
✗ Branch 302 not taken.
✓ Branch 303 taken 978 times.
✗ Branch 304 not taken.
✗ Branch 305 not taken.
✗ Branch 306 not taken.
✗ Branch 307 not taken.
✗ Branch 308 not taken.
✗ Branch 309 not taken.
✗ Branch 310 not taken.
✓ Branch 311 taken 1 times.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✓ Branch 314 taken 586 times.
✓ Branch 315 taken 1275 times.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✓ Branch 319 taken 31 times.
✗ Branch 320 not taken.
✗ Branch 321 not taken.
✗ Branch 322 not taken.
✗ Branch 323 not taken.
✗ Branch 324 not taken.
✗ Branch 325 not taken.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✗ Branch 328 not taken.
✗ Branch 329 not taken.
✓ Branch 330 taken 27143 times.
✓ Branch 331 taken 72 times.
✗ Branch 332 not taken.
✗ Branch 333 not taken.
✓ Branch 334 taken 27147 times.
✓ Branch 335 taken 32659 times.
✓ Branch 336 taken 2703958 times.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✗ Branch 339 not taken.
✗ Branch 340 not taken.
✗ Branch 341 not taken.
✗ Branch 342 not taken.
✗ Branch 343 not taken.
✗ Branch 344 not taken.
✓ Branch 345 taken 2539388 times.
✓ Branch 346 taken 77 times.
✗ Branch 347 not taken.
✗ Branch 348 not taken.
✗ Branch 349 not taken.
✗ Branch 350 not taken.
✗ Branch 351 not taken.
✗ Branch 352 not taken.
✗ Branch 353 not taken.
✓ Branch 354 taken 27 times.
✓ Branch 355 taken 20 times.
✗ Branch 356 not taken.
✗ Branch 357 not taken.
✓ Branch 358 taken 5580678 times.
✓ Branch 359 taken 155432 times.
✓ Branch 360 taken 191294 times.
✓ Branch 361 taken 3 times.
✗ Branch 362 not taken.
✗ Branch 363 not taken.
✗ Branch 364 not taken.
✗ Branch 365 not taken.
✗ Branch 366 not taken.
✓ Branch 367 taken 1427960 times.
✓ Branch 368 taken 62327085 times.
✓ Branch 369 taken 420932 times.
✓ Branch 370 taken 20185267 times.
✓ Branch 371 taken 334428 times.
✓ Branch 372 taken 34306 times.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
✗ Branch 376 not taken.
✓ Branch 377 taken 22 times.
✗ Branch 378 not taken.
✗ Branch 379 not taken.
✗ Branch 380 not taken.
✗ Branch 381 not taken.
✗ Branch 382 not taken.
✗ Branch 383 not taken.
✗ Branch 384 not taken.
✗ Branch 385 not taken.
✗ Branch 386 not taken.
✗ Branch 387 not taken.
✗ Branch 388 not taken.
✗ Branch 389 not taken.
✓ Branch 390 taken 1 times.
✓ Branch 391 taken 384 times.
✓ Branch 392 taken 6883 times.
✓ Branch 393 taken 3319 times.
✗ Branch 394 not taken.
✗ Branch 395 not taken.
✗ Branch 396 not taken.
✗ Branch 397 not taken.
✓ Branch 398 taken 79 times.
✗ Branch 399 not taken.
✗ Branch 400 not taken.
✓ Branch 401 taken 5268 times.
✗ Branch 402 not taken.
✗ Branch 403 not taken.
✓ Branch 404 taken 170875 times.
✗ Branch 405 not taken.
✗ Branch 406 not taken.
✗ Branch 407 not taken.
✗ Branch 408 not taken.
✗ Branch 409 not taken.
✓ Branch 410 taken 79 times.
✓ Branch 411 taken 100 times.
✓ Branch 412 taken 5 times.
✓ Branch 413 taken 3750 times.
✗ Branch 414 not taken.
✗ Branch 415 not taken.
✗ Branch 416 not taken.
✗ Branch 417 not taken.
✗ Branch 418 not taken.
✗ Branch 419 not taken.
✗ Branch 420 not taken.
✗ Branch 421 not taken.
✗ Branch 422 not taken.
✗ Branch 423 not taken.
✓ Branch 424 taken 2567 times.
✗ Branch 425 not taken.
✗ Branch 426 not taken.
✓ Branch 427 taken 10 times.
✗ Branch 428 not taken.
✓ Branch 429 taken 3666 times.
✗ Branch 430 not taken.
✗ Branch 431 not taken.
✗ Branch 432 not taken.
✗ Branch 433 not taken.
✗ Branch 434 not taken.
✓ Branch 435 taken 1201098 times.
✗ Branch 436 not taken.
✓ Branch 437 taken 2753647 times.
✗ Branch 438 not taken.
✗ Branch 439 not taken.
✓ Branch 440 taken 55814 times.
✗ Branch 441 not taken.
✗ Branch 442 not taken.
✗ Branch 443 not taken.
✗ Branch 444 not taken.
✗ Branch 445 not taken.
✗ Branch 446 not taken.
✗ Branch 447 not taken.
✗ Branch 448 not taken.
✓ Branch 449 taken 403497 times.
✓ Branch 450 taken 177544 times.
✗ Branch 451 not taken.
✗ Branch 452 not taken.
✗ Branch 453 not taken.
✗ Branch 454 not taken.
✗ Branch 455 not taken.
✗ Branch 456 not taken.
✗ Branch 457 not taken.
✗ Branch 458 not taken.
✗ Branch 459 not taken.
✗ Branch 460 not taken.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✗ Branch 463 not taken.
✗ Branch 464 not taken.
✗ Branch 465 not taken.
✗ Branch 466 not taken.
✗ Branch 467 not taken.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✗ Branch 471 not taken.
✗ Branch 472 not taken.
✗ Branch 473 not taken.
✗ Branch 474 not taken.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✗ Branch 479 not taken.
✓ Branch 480 taken 22 times.
✗ Branch 481 not taken.
✗ Branch 482 not taken.
✗ Branch 483 not taken.
✗ Branch 484 not taken.
✗ Branch 485 not taken.
✗ Branch 486 not taken.
✗ Branch 487 not taken.
✗ Branch 488 not taken.
✗ Branch 489 not taken.
✗ Branch 490 not taken.
✗ Branch 491 not taken.
✗ Branch 492 not taken.
✗ Branch 493 not taken.
✗ Branch 494 not taken.
✗ Branch 495 not taken.
✗ Branch 496 not taken.
✗ Branch 497 not taken.
✗ Branch 498 not taken.
✗ Branch 499 not taken.
✗ Branch 500 not taken.
✗ Branch 501 not taken.
✗ Branch 502 not taken.
✗ Branch 503 not taken.
✗ Branch 504 not taken.
✗ Branch 505 not taken.
✗ Branch 506 not taken.
✗ Branch 507 not taken.
✓ Branch 508 taken 12 times.
✓ Branch 509 taken 598 times.
✗ Branch 510 not taken.
✓ Branch 511 taken 15644354 times.
✗ Branch 512 not taken.
✓ Branch 513 taken 77262 times.
✗ Branch 514 not taken.
✓ Branch 515 taken 131917 times.
✗ Branch 516 not taken.
✓ Branch 517 taken 21343 times.
✗ Branch 518 not taken.
✓ Branch 519 taken 2363 times.
✗ Branch 520 not taken.
✓ Branch 521 taken 4 times.
✗ Branch 522 not taken.
✓ Branch 523 taken 42 times.
✓ Branch 524 taken 6266198 times.
✓ Branch 525 taken 593592 times.
✓ Branch 526 taken 122622 times.
✗ Branch 527 not taken.
✗ Branch 528 not taken.
✗ Branch 529 not taken.
✓ Branch 530 taken 15079 times.
✗ Branch 531 not taken.
✗ Branch 532 not taken.
✗ Branch 533 not taken.
✓ Branch 534 taken 16271098 times.
✗ Branch 535 not taken.
✗ Branch 536 not taken.
✓ Branch 537 taken 5 times.
✓ Branch 538 taken 354940 times.
✗ Branch 539 not taken.
✗ Branch 540 not taken.
✓ Branch 541 taken 354943 times.
✓ Branch 542 taken 3 times.
✓ Branch 543 taken 3 times.
✓ Branch 544 taken 12696160 times.
✓ Branch 545 taken 60 times.
✗ Branch 546 not taken.
✗ Branch 547 not taken.
✗ Branch 548 not taken.
✗ Branch 549 not taken.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✗ Branch 552 not taken.
✗ Branch 553 not taken.
✗ Branch 554 not taken.
✗ Branch 555 not taken.
✗ Branch 556 not taken.
✗ Branch 557 not taken.
✗ Branch 558 not taken.
✗ Branch 559 not taken.
✗ Branch 560 not taken.
✓ Branch 561 taken 2564 times.
✗ Branch 562 not taken.
✗ Branch 563 not taken.
✗ Branch 564 not taken.
✗ Branch 565 not taken.
✓ Branch 566 taken 26528 times.
✗ Branch 567 not taken.
✓ Branch 568 taken 146 times.
✗ Branch 569 not taken.
✗ Branch 570 not taken.
✗ Branch 571 not taken.
✗ Branch 572 not taken.
✗ Branch 573 not taken.
✗ Branch 574 not taken.
✗ Branch 575 not taken.
✗ Branch 576 not taken.
✗ Branch 577 not taken.
✗ Branch 578 not taken.
✓ Branch 579 taken 16962076 times.
✗ Branch 580 not taken.
✗ Branch 581 not taken.
✗ Branch 582 not taken.
✗ Branch 583 not taken.
✗ Branch 584 not taken.
✗ Branch 585 not taken.
✗ Branch 586 not taken.
✗ Branch 587 not taken.
✗ Branch 588 not taken.
✗ Branch 589 not taken.
✗ Branch 590 not taken.
✓ Branch 591 taken 3535588 times.
✓ Branch 592 taken 1 times.
✗ Branch 593 not taken.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✗ Branch 596 not taken.
✗ Branch 597 not taken.
✗ Branch 598 not taken.
✓ Branch 599 taken 11 times.
✗ Branch 600 not taken.
✗ Branch 601 not taken.
✗ Branch 602 not taken.
✗ Branch 603 not taken.
✗ Branch 604 not taken.
✗ Branch 605 not taken.
✗ Branch 606 not taken.
✗ Branch 607 not taken.
✗ Branch 608 not taken.
✗ Branch 609 not taken.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 612 not taken.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✗ Branch 615 not taken.
✗ Branch 616 not taken.
✗ Branch 617 not taken.
✗ Branch 618 not taken.
✗ Branch 619 not taken.
✗ Branch 620 not taken.
✗ Branch 621 not taken.
✓ Branch 622 taken 16 times.
✗ Branch 623 not taken.
✗ Branch 624 not taken.
✗ Branch 625 not taken.
✗ Branch 626 not taken.
✗ Branch 627 not taken.
✗ Branch 628 not taken.
✗ Branch 629 not taken.
✗ Branch 630 not taken.
✗ Branch 631 not taken.
✗ Branch 632 not taken.
✗ Branch 633 not taken.
✗ Branch 634 not taken.
✗ Branch 635 not taken.
✗ Branch 636 not taken.
✗ Branch 637 not taken.
✗ Branch 638 not taken.
✗ Branch 639 not taken.
✗ Branch 640 not taken.
✗ Branch 641 not taken.
✗ Branch 642 not taken.
✗ Branch 643 not taken.
✗ Branch 644 not taken.
✓ Branch 645 taken 15 times.
✗ Branch 646 not taken.
✗ Branch 647 not taken.
✗ Branch 648 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✗ Branch 651 not taken.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✗ Branch 654 not taken.
✗ Branch 655 not taken.
✗ Branch 656 not taken.
✗ Branch 657 not taken.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✗ Branch 660 not taken.
✗ Branch 661 not taken.
✗ Branch 662 not taken.
✗ Branch 663 not taken.
✗ Branch 664 not taken.
✗ Branch 665 not taken.
✗ Branch 666 not taken.
✗ Branch 667 not taken.
✗ Branch 668 not taken.
✗ Branch 669 not taken.
✗ Branch 670 not taken.
✗ Branch 671 not taken.
✗ Branch 672 not taken.
✗ Branch 673 not taken.
✗ Branch 674 not taken.
✗ Branch 675 not taken.
✗ Branch 676 not taken.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✗ Branch 679 not taken.
✗ Branch 680 not taken.
✗ Branch 681 not taken.
✗ Branch 682 not taken.
✗ Branch 683 not taken.
✗ Branch 684 not taken.
✗ Branch 685 not taken.
✗ Branch 686 not taken.
✗ Branch 687 not taken.
✗ Branch 688 not taken.
✗ Branch 689 not taken.
✗ Branch 690 not taken.
✗ Branch 691 not taken.
✗ Branch 692 not taken.
✗ Branch 693 not taken.
✗ Branch 694 not taken.
✗ Branch 695 not taken.
✗ Branch 696 not taken.
✗ Branch 697 not taken.
✗ Branch 698 not taken.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✗ Branch 702 not taken.
✗ Branch 703 not taken.
✗ Branch 704 not taken.
✗ Branch 705 not taken.
✗ Branch 706 not taken.
✗ Branch 707 not taken.
✗ Branch 708 not taken.
✗ Branch 709 not taken.
✗ Branch 710 not taken.
✗ Branch 711 not taken.
✗ Branch 712 not taken.
✗ Branch 713 not taken.
✗ Branch 714 not taken.
✗ Branch 715 not taken.
✗ Branch 716 not taken.
✗ Branch 717 not taken.
✗ Branch 718 not taken.
✗ Branch 719 not taken.
✗ Branch 720 not taken.
✗ Branch 721 not taken.
✗ Branch 722 not taken.
✗ Branch 723 not taken.
✗ Branch 724 not taken.
✗ Branch 725 not taken.
✗ Branch 726 not taken.
✗ Branch 727 not taken.
✗ Branch 728 not taken.
✗ Branch 729 not taken.
✗ Branch 730 not taken.
✗ Branch 731 not taken.
✗ Branch 732 not taken.
✗ Branch 733 not taken.
✗ Branch 734 not taken.
✗ Branch 735 not taken.
✗ Branch 736 not taken.
✗ Branch 737 not taken.
✗ Branch 738 not taken.
✗ Branch 739 not taken.
✗ Branch 740 not taken.
✗ Branch 741 not taken.
✗ Branch 742 not taken.
✗ Branch 743 not taken.
✗ Branch 744 not taken.
✗ Branch 745 not taken.
✗ Branch 746 not taken.
✗ Branch 747 not taken.
✗ Branch 748 not taken.
✗ Branch 749 not taken.
✗ Branch 750 not taken.
✗ Branch 751 not taken.
✗ Branch 752 not taken.
✗ Branch 753 not taken.
✗ Branch 754 not taken.
✗ Branch 755 not taken.
✗ Branch 756 not taken.
✗ Branch 757 not taken.
✗ Branch 758 not taken.
✗ Branch 759 not taken.
✗ Branch 760 not taken.
✗ Branch 761 not taken.
✗ Branch 762 not taken.
✗ Branch 763 not taken.
✗ Branch 764 not taken.
✗ Branch 765 not taken.
✗ Branch 766 not taken.
✗ Branch 767 not taken.
✗ Branch 768 not taken.
✗ Branch 769 not taken.
✗ Branch 770 not taken.
✗ Branch 771 not taken.
✗ Branch 772 not taken.
✗ Branch 773 not taken.
✗ Branch 774 not taken.
✗ Branch 775 not taken.
✗ Branch 776 not taken.
✗ Branch 777 not taken.
✗ Branch 778 not taken.
✗ Branch 779 not taken.
✗ Branch 780 not taken.
✗ Branch 781 not taken.
✗ Branch 782 not taken.
✗ Branch 783 not taken.
✗ Branch 784 not taken.
✗ Branch 785 not taken.
✗ Branch 786 not taken.
✗ Branch 787 not taken.
✗ Branch 788 not taken.
✗ Branch 789 not taken.
✗ Branch 790 not taken.
✗ Branch 791 not taken.
✗ Branch 792 not taken.
✗ Branch 793 not taken.
✗ Branch 794 not taken.
✗ Branch 795 not taken.
✗ Branch 796 not taken.
✗ Branch 797 not taken.
✗ Branch 798 not taken.
✗ Branch 799 not taken.
✗ Branch 800 not taken.
✗ Branch 801 not taken.
✗ Branch 802 not taken.
✗ Branch 803 not taken.
✗ Branch 804 not taken.
✗ Branch 805 not taken.
✗ Branch 806 not taken.
✗ Branch 807 not taken.
✗ Branch 808 not taken.
✗ Branch 809 not taken.
✗ Branch 810 not taken.
✗ Branch 811 not taken.
✗ Branch 812 not taken.
✗ Branch 813 not taken.
✗ Branch 814 not taken.
✗ Branch 815 not taken.
✗ Branch 816 not taken.
✗ Branch 817 not taken.
✗ Branch 818 not taken.
✗ Branch 819 not taken.
✗ Branch 820 not taken.
✗ Branch 821 not taken.
✗ Branch 822 not taken.
✗ Branch 823 not taken.
✗ Branch 824 not taken.
✗ Branch 825 not taken.
✗ Branch 826 not taken.
✗ Branch 827 not taken.
✗ Branch 828 not taken.
✗ Branch 829 not taken.
✗ Branch 830 not taken.
✗ Branch 831 not taken.
✗ Branch 832 not taken.
✗ Branch 833 not taken.
✗ Branch 834 not taken.
✗ Branch 835 not taken.
✗ Branch 836 not taken.
✗ Branch 837 not taken.
✗ Branch 838 not taken.
✗ Branch 839 not taken.
✗ Branch 840 not taken.
✗ Branch 841 not taken.
✗ Branch 842 not taken.
✗ Branch 843 not taken.
✗ Branch 844 not taken.
✗ Branch 845 not taken.
✗ Branch 846 not taken.
✗ Branch 847 not taken.
✗ Branch 848 not taken.
✓ Branch 849 taken 8 times.
✗ Branch 850 not taken.
✗ Branch 851 not taken.
✗ Branch 852 not taken.
✗ Branch 853 not taken.
✗ Branch 854 not taken.
✗ Branch 855 not taken.
✗ Branch 856 not taken.
✗ Branch 857 not taken.
✗ Branch 858 not taken.
✗ Branch 859 not taken.
✗ Branch 860 not taken.
✗ Branch 861 not taken.
✗ Branch 862 not taken.
✗ Branch 863 not taken.
✗ Branch 864 not taken.
✗ Branch 865 not taken.
✗ Branch 866 not taken.
✗ Branch 867 not taken.
✗ Branch 868 not taken.
✗ Branch 869 not taken.
✗ Branch 870 not taken.
✗ Branch 871 not taken.
✗ Branch 872 not taken.
✗ Branch 873 not taken.
✗ Branch 874 not taken.
✗ Branch 875 not taken.
✗ Branch 876 not taken.
✗ Branch 877 not taken.
✗ Branch 878 not taken.
✗ Branch 879 not taken.
✗ Branch 880 not taken.
✗ Branch 881 not taken.
✓ Branch 882 taken 1 times.
✗ Branch 883 not taken.
✗ Branch 884 not taken.
✓ Branch 885 taken 1 times.
✗ Branch 886 not taken.
✓ Branch 887 taken 279 times.
✗ Branch 888 not taken.
✗ Branch 889 not taken.
✗ Branch 890 not taken.
✗ Branch 891 not taken.
✗ Branch 892 not taken.
✗ Branch 893 not taken.
✗ Branch 894 not taken.
✗ Branch 895 not taken.
✗ Branch 896 not taken.
✗ Branch 897 not taken.
✗ Branch 898 not taken.
✗ Branch 899 not taken.
✗ Branch 900 not taken.
✗ Branch 901 not taken.
✗ Branch 902 not taken.
✗ Branch 903 not taken.
✗ Branch 904 not taken.
✗ Branch 905 not taken.
✗ Branch 906 not taken.
✓ Branch 907 taken 1338 times.
✓ Branch 908 taken 301905 times.
✗ Branch 909 not taken.
✗ Branch 910 not taken.
✗ Branch 911 not taken.
✓ Branch 912 taken 73 times.
✗ Branch 913 not taken.
✓ Branch 914 taken 6 times.
✓ Branch 915 taken 8 times.
✓ Branch 916 taken 68 times.
✓ Branch 917 taken 10 times.
✗ Branch 918 not taken.
✗ Branch 919 not taken.
✗ Branch 920 not taken.
✗ Branch 921 not taken.
✗ Branch 922 not taken.
✗ Branch 923 not taken.
✗ Branch 924 not taken.
✗ Branch 925 not taken.
✗ Branch 926 not taken.
✗ Branch 927 not taken.
✗ Branch 928 not taken.
705810520 switch(scommand)
35970 {
35971 //always first
35972 case 0xFFFF: //invalid command
35973 {
35974 const char* type_str = ScriptTypeToString(type);
35975 switch(type)
35976 {
35977 case ScriptType::FFC:
35978 zprint("%s Script %s has exited.\n", type_str, ffcmap[i].scriptname.c_str()); break;
35979 case ScriptType::NPC:
35980 zprint("%s Script %s has exited.\n", type_str, npcmap[i].scriptname.c_str()); break;
35981 case ScriptType::Lwpn:
35982 zprint("%s Script %s has exited.\n", type_str, lwpnmap[i].scriptname.c_str()); break;
35983 case ScriptType::Ewpn:
35984 zprint("%s Script %s has exited.\n", type_str, ewpnmap[i].scriptname.c_str()); break;
35985 case ScriptType::ItemSprite:
35986 zprint("%s Script %s has exited.\n", type_str, itemspritemap[i].scriptname.c_str()); break;
35987 case ScriptType::Item:
35988 zprint("%s Script %s has exited.\n", type_str, itemmap[i].scriptname.c_str()); break;
35989 case ScriptType::Global:
35990 zprint("%s Script %s has exited.\n", type_str, globalmap[i].scriptname.c_str()); break;
35991 case ScriptType::Player:
35992 zprint("%s Script %s has exited.\n", type_str, playermap[i].scriptname.c_str()); break;
35993 case ScriptType::Screen:
35994 zprint("%s Script %s has exited.\n", type_str, screenmap[i].scriptname.c_str()); break;
35995 case ScriptType::OnMap:
35996 case ScriptType::DMap:
35997 case ScriptType::ScriptedActiveSubscreen:
35998 case ScriptType::ScriptedPassiveSubscreen:
35999 zprint("%s Script %s has exited.\n", type_str, dmapmap[i].scriptname.c_str()); break;
36000 case ScriptType::Combo: zprint("%s Script %s has exited.\n", type_str, comboscriptmap[i].scriptname.c_str()); break;
36001
36002 default: break;
36003 }
36004 break;
36005 }
36006 case QUIT:
36007 69460 scommand = 0xFFFF;
36008 69460 break;
36009 case QUIT_NO_DEALLOC:
36010 scommand = 0xFFFF;
36011 no_dealloc = true;
36012 break;
36013
36014 case NOP: //No Operation. Do nothing. -Em
36015 break;
36016 case GOTO:
36017 {
36018 uint8_t invalid = 0;
36019 if(sarg1 < 0 )
36020 {
36021 const char* type_str = ScriptTypeToString(type);
36022 switch(type)
36023 {
36024 case ScriptType::FFC:
36025 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
36026 case ScriptType::NPC:
36027 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
36028 case ScriptType::Lwpn:
36029 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
36030 case ScriptType::Ewpn:
36031 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
36032 case ScriptType::ItemSprite:
36033 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
36034 case ScriptType::Item:
36035 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
36036 case ScriptType::Global:
36037 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
36038 case ScriptType::Player:
36039 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
36040 case ScriptType::Screen:
36041 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
36042 case ScriptType::OnMap:
36043 case ScriptType::DMap:
36044 case ScriptType::ScriptedActiveSubscreen:
36045 case ScriptType::ScriptedPassiveSubscreen:
36046 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
36047 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
36048
36049 default: break;
36050 }
36051 invalid = 1; scommand = 0xFFFF;
36052 }
36053 if ( invalid ) break;
36054 ri->pc = sarg1;
36055 increment = false;
36056 break;
36057 }
36058 case GOTOR:
36059 {
36060 uint8_t invalid = 0;
36061 if(sarg1 < 0 )
36062 {
36063 const char* type_str = ScriptTypeToString(type);
36064 switch(type)
36065 {
36066 case ScriptType::FFC:
36067 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str() ,sarg1); break;
36068 case ScriptType::NPC:
36069 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
36070 case ScriptType::Lwpn:
36071 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
36072 case ScriptType::Ewpn:
36073 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
36074 case ScriptType::ItemSprite:
36075 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
36076 case ScriptType::Item:
36077 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
36078 case ScriptType::Global:
36079 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
36080 case ScriptType::Player:
36081 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
36082 case ScriptType::Screen:
36083 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
36084 case ScriptType::OnMap:
36085 case ScriptType::DMap:
36086 case ScriptType::ScriptedActiveSubscreen:
36087 case ScriptType::ScriptedPassiveSubscreen:
36088 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
36089 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
36090
36091 default: break;
36092 }
36093 invalid = 1; scommand = 0xFFFF;
36094 }
36095 if ( invalid ) break;
36096 ri->pc = (get_register(sarg1) / 10000) - 1;
36097 increment = false;
36098 }
36099 break;
36100
36101 case GOTOTRUE:
36102 if(ri->scriptflag & TRUEFLAG)
36103 {
36104 uint8_t invalid = 0;
36105 if(sarg1 < 0 )
36106 {
36107 const char* type_str = ScriptTypeToString(type);
36108 switch(type)
36109 {
36110 case ScriptType::FFC:
36111 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
36112 case ScriptType::NPC:
36113 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
36114 case ScriptType::Lwpn:
36115 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
36116 case ScriptType::Ewpn:
36117 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
36118 case ScriptType::ItemSprite:
36119 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
36120 case ScriptType::Item:
36121 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
36122 case ScriptType::Global:
36123 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
36124 case ScriptType::Player:
36125 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
36126 case ScriptType::Screen:
36127 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
36128 case ScriptType::OnMap:
36129 case ScriptType::DMap:
36130 case ScriptType::ScriptedActiveSubscreen:
36131 case ScriptType::ScriptedPassiveSubscreen:
36132 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
36133 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
36134
36135 default: break;
36136 }
36137 invalid = 1; scommand = 0xFFFF;
36138 }
36139 if ( invalid ) break;
36140 ri->pc = sarg1;
36141 increment = false;
36142 }
36143
36144 break;
36145
36146 case GOTOFALSE:
36147 if(!(ri->scriptflag & TRUEFLAG))
36148 {
36149 uint8_t invalid = 0;
36150 if(sarg1 < 0 )
36151 {
36152 const char* type_str = ScriptTypeToString(type);
36153 switch(type)
36154 {
36155 case ScriptType::FFC:
36156 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
36157 case ScriptType::NPC:
36158 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
36159 case ScriptType::Lwpn:
36160 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
36161 case ScriptType::Ewpn:
36162 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
36163 case ScriptType::ItemSprite:
36164 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
36165 case ScriptType::Item:
36166 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
36167 case ScriptType::Global:
36168 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
36169 case ScriptType::Player:
36170 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
36171 case ScriptType::Screen:
36172 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
36173 case ScriptType::OnMap:
36174 case ScriptType::DMap:
36175 case ScriptType::ScriptedActiveSubscreen:
36176 case ScriptType::ScriptedPassiveSubscreen:
36177 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
36178 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
36179
36180 default: break;
36181 }
36182 invalid = 1; scommand = 0xFFFF;
36183 }
36184 if ( invalid ) break;
36185 ri->pc = sarg1;
36186 increment = false;
36187 }
36188
36189 break;
36190
36191 case GOTOMORE:
36192 if(ri->scriptflag & MOREFLAG)
36193 {
36194 uint8_t invalid = 0;
36195 if(sarg1 < 0 )
36196 {
36197 const char* type_str = ScriptTypeToString(type);
36198 switch(type)
36199 {
36200 case ScriptType::FFC:
36201 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
36202 case ScriptType::NPC:
36203 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
36204 case ScriptType::Lwpn:
36205 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
36206 case ScriptType::Ewpn:
36207 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
36208 case ScriptType::ItemSprite:
36209 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
36210 case ScriptType::Item:
36211 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
36212 case ScriptType::Global:
36213 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
36214 case ScriptType::Player:
36215 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
36216 case ScriptType::Screen:
36217 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
36218 case ScriptType::OnMap:
36219 case ScriptType::DMap:
36220 case ScriptType::ScriptedActiveSubscreen:
36221 case ScriptType::ScriptedPassiveSubscreen:
36222 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
36223 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
36224
36225 default: break;
36226 }
36227 invalid = 1; scommand = 0xFFFF;
36228 }
36229 if ( invalid ) break;
36230 ri->pc = sarg1;
36231 increment = false;
36232 }
36233
36234 break;
36235
36236 case GOTOLESS:
36237 if(!(ri->scriptflag & MOREFLAG) || (!get_qr(qr_GOTOLESSNOTEQUAL) && (ri->scriptflag & TRUEFLAG)))
36238 {
36239 uint8_t invalid = 0;
36240 if(sarg1 < 0 )
36241 {
36242 const char* type_str = ScriptTypeToString(type);
36243 switch(type)
36244 {
36245 case ScriptType::FFC:
36246 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
36247 case ScriptType::NPC:
36248 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
36249 case ScriptType::Lwpn:
36250 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
36251 case ScriptType::Ewpn:
36252 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
36253 case ScriptType::ItemSprite:
36254 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
36255 case ScriptType::Item:
36256 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
36257 case ScriptType::Global:
36258 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
36259 case ScriptType::Player:
36260 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
36261 case ScriptType::Screen:
36262 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
36263 case ScriptType::OnMap:
36264 case ScriptType::DMap:
36265 case ScriptType::ScriptedActiveSubscreen:
36266 case ScriptType::ScriptedPassiveSubscreen:
36267 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
36268 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
36269
36270 default: break;
36271 }
36272 invalid = 1; scommand = 0xFFFF;
36273 }
36274 if ( invalid ) break;
36275 ri->pc = sarg1;
36276 increment = false;
36277 }
36278
36279 break;
36280
36281 case LOOP:
36282 {
36283 if(get_register(sarg2) > 0)
36284 {
36285 ri->pc = sarg1;
36286 increment = false;
36287 }
36288 else
36289 {
36290 set_register(sarg1, sarg1 - 1);
36291 }
36292 }
36293 break;
36294
36295 case RETURN:
36296 {
36297 if (script_funcrun)
36298 break; //handled below
36299 ri->pc = SH::read_stack(ri->sp) - 1;
36300 ++ri->sp;
36301 ri->sp &= MASK_SP;
36302 increment = false;
36303 break;
36304 }
36305
36306 case SETTRUE:
36307 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 1 : 0);
36308 break;
36309
36310 case SETFALSE:
36311 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 0 : 1);
36312 break;
36313
36314 case SETMORE:
36315 set_register(sarg1, (ri->scriptflag & MOREFLAG) ? 1 : 0);
36316 break;
36317
36318 case SETLESS:
36319 set_register(sarg1, (!(ri->scriptflag & MOREFLAG)
36320 || (ri->scriptflag & TRUEFLAG)) ? 1 : 0);
36321 break;
36322
36323 case SETTRUEI:
36324 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 10000 : 0);
36325 break;
36326
36327 case SETFALSEI:
36328 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 0 : 10000);
36329 break;
36330
36331 case SETMOREI:
36332 set_register(sarg1, (ri->scriptflag & MOREFLAG) ? 10000 : 0);
36333 break;
36334
36335 case SETLESSI:
36336 set_register(sarg1, (!(ri->scriptflag & MOREFLAG)
36337 || (ri->scriptflag & TRUEFLAG)) ? 10000 : 0);
36338 break;
36339
36340 case READPODARRAYR:
36341 {
36342 62479687 do_readpod(false);
36343 62479687 break;
36344 }
36345 case READPODARRAYV:
36346 {
36347 31878579 do_readpod(true);
36348 31878579 break;
36349 }
36350 case WRITEPODARRAYRR:
36351 {
36352 38051438 do_writepod(false,false);
36353 38051438 break;
36354 }
36355 case WRITEPODARRAYRV:
36356 {
36357 do_writepod(false,true);
36358 break;
36359 }
36360 case WRITEPODARRAYVR:
36361 {
36362 22087237 do_writepod(true,false);
36363 22087237 break;
36364 }
36365 case WRITEPODARRAYVV:
36366 {
36367 2928911 do_writepod(true,true);
36368 2928911 break;
36369 }
36370 case WRITEPODSTRING:
36371 {
36372 236286 do_writepodstr();
36373 236286 break;
36374 }
36375 case WRITEPODARRAY:
36376 {
36377 302 do_writepodarr();
36378 302 break;
36379 }
36380 case ZCLASS_CONSTRUCT:
36381 {
36382 do_constructclass(type,script,i);
36383 break;
36384 }
36385 case ZCLASS_READ:
36386 {
36387 do_readclass();
36388 break;
36389 }
36390 case ZCLASS_WRITE:
36391 {
36392 do_writeclass();
36393 break;
36394 }
36395 case ZCLASS_FREE:
36396 {
36397 do_freeclass();
36398 break;
36399 }
36400 case ZCLASS_OWN:
36401 {
36402 if(user_object* obj = checkObject(get_register(sarg1), true))
36403 {
36404 obj->own(type,i);
36405 }
36406 break;
36407 }
36408 case STARTDESTRUCTOR:
36409 {
36410 zprint2("STARTDESTRUCTOR: %s\n", sargstr->c_str());
36411 //This opcode's EXISTENCE indicates the first opcode
36412 //of a user_object destructor function.
36413 break;
36414 }
36415 case ZCLASS_GLOBALIZE:
36416 {
36417 if(user_object* obj = checkObject(get_register(sarg1), true))
36418 {
36419 obj->disown();
36420 }
36421 break;
36422 }
36423
36424 case NOT:
36425 do_not(false);
36426 break;
36427
36428 case COMPAREV:
36429 do_comp(true);
36430 break;
36431 case COMPAREV2:
36432 do_comp(true,true);
36433 break;
36434
36435 case COMPARER:
36436 do_comp(false);
36437 break;
36438
36439 case STRCMPR:
36440 do_internal_strcmp();
36441 break;
36442
36443 case STRICMPR:
36444 do_internal_stricmp();
36445 break;
36446
36447 case SETV:
36448 do_set(true, type, i);
36449 break;
36450
36451 case SETR:
36452 do_set(false, type, i);
36453 break;
36454
36455 case PUSHR:
36456 do_push(false);
36457 break;
36458
36459 case PUSHV:
36460 do_push(true);
36461 break;
36462
36463 case PEEK:
36464 72811 do_peek();
36465 72811 break;
36466 case PEEKATV:
36467 do_peekat(true);
36468 break;
36469 case POP:
36470 do_pop();
36471 break;
36472
36473 case POPARGS:
36474 do_pops();
36475 break;
36476
36477 case LOADI:
36478 do_loadi();
36479 break;
36480
36481 case STOREI:
36482 do_storei();
36483 break;
36484
36485 case LOADD:
36486 do_loadd();
36487 break;
36488
36489 case STORED:
36490 do_stored();
36491 break;
36492
36493 case LOAD1:
36494 do_loada(0);
36495 break;
36496
36497 case LOAD2:
36498 do_loada(1);
36499 break;
36500
36501 case SETA1:
36502 do_seta(0);
36503 break;
36504
36505 case SETA2:
36506 do_seta(1);
36507 break;
36508
36509 case ALLOCATEGMEMR:
36510 if(type == ScriptType::Global) do_allocatemem(false, false, type, i);
36511
36512 break;
36513
36514 case ALLOCATEGMEMV:
36515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 302 times.
302 if(type == ScriptType::Global) do_allocatemem(true, false, type, i);
36516
36517 302 break;
36518
36519 case ALLOCATEMEMR:
36520 do_allocatemem(false, true, type, i);
36521 break;
36522
36523 case ALLOCATEMEMV:
36524 7008212 do_allocatemem(true, true, type, i);
36525 7008212 break;
36526
36527 case RESIZEARRAYR:
36528 do_resize_array();
36529 break;
36530 case OWNARRAYR:
36531 do_own_array(get_register(sarg1)/10000, type, i);
36532 break;
36533 case DESTROYARRAYR:
36534 do_destroy_array();
36535 break;
36536
36537 case DEALLOCATEMEMR:
36538 6983690 do_deallocatemem();
36539 6983690 break;
36540
36541 case SAVEGAMESTRUCTS:
36542 using_SRAM = 1;
36543 FFCore.do_savegamestructs(false,false);
36544 using_SRAM = 0;
36545 break;
36546 case READGAMESTRUCTS:
36547 using_SRAM = 1;
36548 FFCore.do_loadgamestructs(false,false);
36549 using_SRAM = 0;
36550 break;
36551 case ARRAYSIZE:
36552 294114397 do_arraysize();
36553 294114397 break;
36554 case ARRAYSIZEB:
36555 do_arraysize();
36556 break;
36557 case ARRAYSIZEF:
36558 do_arraysize();
36559 break;
36560 case ARRAYSIZEN:
36561 do_arraysize();
36562 break;
36563 case ARRAYSIZEI:
36564 do_arraysize();
36565 break;
36566 case ARRAYSIZEID:
36567 do_arraysize();
36568 break;
36569 case ARRAYSIZEL:
36570 do_arraysize();
36571 break;
36572 case ARRAYSIZEE:
36573 do_arraysize();
36574 break;
36575
36576 case GETFFCSCRIPT:
36577 227724 do_getffcscript();
36578 227724 break;
36579 case GETITEMSCRIPT:
36580 80 do_getitemscript();
36581 80 break;
36582
36583 case CASTBOOLI:
36584 do_boolcast(false);
36585 break;
36586
36587 case CASTBOOLF:
36588 do_boolcast(true);
36589 break;
36590
36591 case ADDV:
36592 do_add(true);
36593 break;
36594
36595 case ADDR:
36596 do_add(false);
36597 break;
36598
36599 case SUBV:
36600 do_sub(true);
36601 break;
36602 case SUBV2:
36603 do_sub(true,true);
36604 break;
36605
36606 case SUBR:
36607 do_sub(false);
36608 break;
36609
36610 case MULTV:
36611 do_mult(true);
36612 break;
36613
36614 case MULTR:
36615 do_mult(false);
36616 break;
36617
36618 case DIVV:
36619 do_div(true);
36620 break;
36621 case DIVV2:
36622 708 do_div(true,true);
36623 708 break;
36624
36625 case DIVR:
36626 do_div(false);
36627 break;
36628
36629 case MODV:
36630 do_mod(true);
36631 break;
36632 case MODV2:
36633 252 do_mod(true,true);
36634 252 break;
36635
36636 case MODR:
36637 do_mod(false);
36638 break;
36639
36640 case SINV:
36641 do_trig(true, 0);
36642 break;
36643
36644 case SINR:
36645 6164970 do_trig(false, 0);
36646 6164970 break;
36647
36648 case COSV:
36649 do_trig(true, 1);
36650 break;
36651
36652 case COSR:
36653 3205819 do_trig(false, 1);
36654 3205819 break;
36655
36656 case TANV:
36657 do_trig(true, 2);
36658 break;
36659
36660 case TANR:
36661 76 do_trig(false, 2);
36662 76 break;
36663
36664 case DEGTORAD:
36665 1263 do_degtorad();
36666 1263 break;
36667
36668 case RADTODEG:
36669 60936 do_radtodeg();
36670 60936 break;
36671
36672 case STRINGLENGTH:
36673 FFCore.do_strlen(false);
36674 break;
36675
36676 case ARCSINR:
36677 14918 do_asin(false);
36678 14918 break;
36679
36680 case ARCCOSR:
36681 do_acos(false);
36682 break;
36683
36684 case ARCTANR:
36685 864999 do_arctan();
36686 864999 break;
36687
36688 //Text ptr functions
36689 case FONTHEIGHTR:
36690 do_fontheight();
36691 break;
36692 case STRINGWIDTHR:
36693 13724 do_strwidth();
36694 13724 break;
36695 case CHARWIDTHR:
36696 15144 do_charwidth();
36697 15144 break;
36698 case MESSAGEWIDTHR:
36699 ri->d[rEXP1] = 10000* do_msgwidth(get_register(sarg1)/10000, "Text->MessageWidth()");
36700 break;
36701 case MESSAGEHEIGHTR:
36702 ri->d[rEXP1] = 10000* do_msgheight(get_register(sarg1)/10000, "Text->MessageHeight()");
36703 break;
36704 //
36705
36706 //String.h functions 2.55 Alpha 23
36707 1 case STRINGCOMPARE: FFCore.do_strcmp(); break;
36708 case STRINGICOMPARE: FFCore.do_stricmp(); break;
36709 93 case STRINGCOPY: FFCore.do_strcpy(false,false); break;
36710 case ARRAYCOPY: FFCore.do_arraycpy(false,false); break;
36711 case STRINGNCOMPARE: FFCore.do_strncmp(); break;
36712 case STRINGNICOMPARE: FFCore.do_strnicmp(); break;
36713
36714 //More string.h functions, 19th May, 2019
36715 case XLEN: FFCore.do_xlen(false); break;
36716 case XTOI: FFCore.do_xtoi(false); break;
36717 case ILEN: FFCore.do_ilen(false); break;
36718 case ATOI: FFCore.do_atoi(false); break;
36719 case STRCSPN: FFCore.do_strcspn(); break;
36720 case STRSTR: FFCore.do_strstr(); break;
36721 case XTOA: FFCore.do_xtoa(); break;
36722 978 case ITOA: FFCore.do_itoa(); break;
36723 case ITOACAT: FFCore.do_itoacat(); break;
36724 case STRCAT: FFCore.do_strcat(); break;
36725 case STRSPN: FFCore.do_strspn(); break;
36726 case STRCHR: FFCore.do_strchr(); break;
36727 case STRRCHR: FFCore.do_strrchr(); break;
36728 case XLEN2: FFCore.do_xlen2(); break;
36729 case XTOI2: FFCore.do_xtoi2(); break;
36730 case ILEN2: FFCore.do_ilen2(); break;
36731 case ATOI2: FFCore.do_atoi2(); break;
36732 case REMCHR2: FFCore.do_remchr2(); break;
36733 case UPPERTOLOWER: FFCore.do_UpperToLower(false); break;
36734 1 case LOWERTOUPPER: FFCore.do_LowerToUpper(false); break;
36735 case CONVERTCASE: FFCore.do_ConvertCase(false); break;
36736
36737 case GETNPCSCRIPT: FFCore.do_getnpcscript(); break;
36738 case GETCOMBOSCRIPT: FFCore.do_getcomboscript(); break;
36739 586 case GETLWEAPONSCRIPT: FFCore.do_getlweaponscript(); break;
36740 1275 case GETEWEAPONSCRIPT: FFCore.do_geteweaponscript(); break;
36741 case GETHEROSCRIPT: FFCore.do_getheroscript(); break;
36742 68 case GETGENERICSCRIPT: FFCore.do_getgenericscript(); break;
36743 case GETGLOBALSCRIPT: FFCore.do_getglobalscript(); break;
36744 102 case GETDMAPSCRIPT: FFCore.do_getdmapscript(); break;
36745 case GETSCREENSCRIPT: FFCore.do_getscreenscript(); break;
36746 31 case GETSPRITESCRIPT: FFCore.do_getitemspritescript(); break;
36747 case GETUNTYPEDSCRIPT: FFCore.do_getuntypedscript(); break;
36748 case GETSUBSCREENSCRIPT:FFCore.do_getsubscreenscript(); break;
36749 case GETNPCBYNAME: FFCore.do_getnpcbyname(); break;
36750 case GETITEMBYNAME: FFCore.do_getitembyname(); break;
36751 case GETCOMBOBYNAME: FFCore.do_getcombobyname(); break;
36752 case GETDMAPBYNAME: FFCore.do_getdmapbyname(); break;
36753
36754 case ABSR:
36755 do_abs(false);
36756 break;
36757
36758 case MINR:
36759 do_min(false);
36760 break;
36761
36762 case MINV:
36763 do_min(true);
36764 break;
36765
36766 case MAXR:
36767 do_max(false);
36768 break;
36769 case MAXV:
36770 do_max(true);
36771 break;
36772
36773 case MAXVARG:
36774 27143 FFCore.do_varg_max();
36775 27143 break;
36776 case MINVARG:
36777 72 FFCore.do_varg_min();
36778 72 break;
36779 case CHOOSEVARG:
36780 FFCore.do_varg_choose();
36781 break;
36782 case MAKEVARGARRAY:
36783 FFCore.do_varg_makearray(type,i);
36784 break;
36785
36786 case PUSHVARGV:
36787 27147 do_push_varg(true);
36788 27147 break;
36789 case PUSHVARGR:
36790 32659 do_push_varg(false);
36791 32659 break;
36792
36793 case RNDR:
36794 2703958 do_rnd(false);
36795 2703958 break;
36796
36797 case RNDV:
36798 do_rnd(true);
36799 break;
36800
36801 case SRNDR:
36802 do_srnd(false);
36803 break;
36804
36805 case SRNDV:
36806 do_srnd(true);
36807 break;
36808
36809 case SRNDRND:
36810 do_srndrnd();
36811 break;
36812
36813 case GETRTCTIMER:
36814 FFCore.getRTC(false);
36815 break;
36816 case GETRTCTIMEV:
36817 FFCore.getRTC(true);
36818 break;
36819
36820 case FACTORIAL:
36821 do_factorial(false);
36822 break;
36823
36824 case SQROOTV:
36825 do_sqroot(true);
36826 break;
36827
36828 case SQROOTR:
36829 2539388 do_sqroot(false);
36830 2539388 break;
36831
36832 case POWERR:
36833 77 do_power(false);
36834 77 break;
36835 case POWERV:
36836 do_power(true);
36837 break;
36838 case POWERV2:
36839 do_power(true,true);
36840 break;
36841
36842 case LPOWERR:
36843 do_lpower(false);
36844 break;
36845 case LPOWERV:
36846 do_lpower(true);
36847 break;
36848 case LPOWERV2:
36849 do_lpower(true,true);
36850 break;
36851
36852 case IPOWERR:
36853 do_ipower(false);
36854 break;
36855
36856 case IPOWERV:
36857 do_ipower(true);
36858 break;
36859
36860 case LOG10:
36861 27 do_log10(false);
36862 27 break;
36863
36864 case LOGE:
36865 20 do_naturallog(false);
36866 20 break;
36867
36868 case ANDR:
36869 do_and(false);
36870 break;
36871
36872 case ANDV:
36873 do_and(true);
36874 break;
36875
36876 case ORR:
36877 5580678 do_or(false);
36878 5580678 break;
36879
36880 case ORV:
36881 155432 do_or(true);
36882 155432 break;
36883
36884 case XORR:
36885 191294 do_xor(false);
36886 191294 break;
36887
36888 case XORV:
36889 3 do_xor(true);
36890 3 break;
36891
36892 case NANDR:
36893 do_nand(false);
36894 break;
36895
36896 case NANDV:
36897 do_nand(true);
36898 break;
36899
36900 case NORR:
36901 do_nor(false);
36902 break;
36903
36904 case NORV:
36905 do_nor(true);
36906 break;
36907
36908 case XNORR:
36909 do_xnor(false);
36910 break;
36911
36912 case XNORV:
36913 do_xnor(true);
36914 break;
36915
36916 case BITNOT:
36917 1427960 do_bitwisenot(false);
36918 1427960 break;
36919
36920 case LSHIFTR:
36921 62327085 do_lshift(false);
36922 62327085 break;
36923
36924 case LSHIFTV:
36925 420932 do_lshift(true);
36926 420932 break;
36927
36928 case RSHIFTR:
36929 20185267 do_rshift(false);
36930 20185267 break;
36931
36932 case RSHIFTV:
36933 334428 do_rshift(true);
36934 334428 break;
36935
36936 case ANDR32:
36937 34306 do_and32(false);
36938 34306 break;
36939
36940 case ANDV32:
36941 do_and32(true);
36942 break;
36943
36944 case ORR32:
36945 17 do_or32(false);
36946 17 break;
36947
36948 case ORV32:
36949 do_or32(true);
36950 break;
36951
36952 case XORR32:
36953 do_xor32(false);
36954 break;
36955
36956 case XORV32:
36957 do_xor32(true);
36958 break;
36959
36960 case BITNOT32:
36961 do_bitwisenot32(false);
36962 break;
36963
36964 case LSHIFTR32:
36965 22 do_lshift32(false);
36966 22 break;
36967
36968 case LSHIFTV32:
36969 do_lshift32(true);
36970 break;
36971
36972 case RSHIFTR32:
36973 34296 do_rshift32(false);
36974 34296 break;
36975
36976 case RSHIFTV32:
36977 do_rshift32(true);
36978 break;
36979
36980 case TRACER:
36981 3553 FFCore.do_trace(false);
36982 3553 break;
36983
36984 case TRACELR:
36985 FFCore.do_tracel(false);
36986 break;
36987
36988 case TRACEV:
36989 FFCore.do_trace(true);
36990 break;
36991
36992 case TRACE2R:
36993 FFCore.do_tracebool(false);
36994 break;
36995
36996 //Zap and Wavy Effects
36997 case FXWAVYR:
36998 FFCore.do_fx_wavy(false);
36999 break;
37000 case FXZAPR:
37001 FFCore.do_fx_zap(false);
37002 break;
37003 //Zap and Wavy Effects
37004 case FXWAVYV:
37005 FFCore.do_fx_wavy(true);
37006 break;
37007 case FXZAPV:
37008 FFCore.do_fx_zap(true);
37009 break;
37010 case GREYSCALER:
37011 FFCore.do_greyscale(false);
37012 break;
37013 case GREYSCALEV:
37014 FFCore.do_greyscale(true);
37015 break;
37016 case MONOCHROMER:
37017 FFCore.do_monochromatic(false);
37018 break;
37019 case MONOCHROMEV:
37020 FFCore.do_monochromatic(true);
37021 break;
37022
37023 case TRACE2V:
37024 FFCore.do_tracebool(true);
37025 break;
37026
37027 case TRACE3:
37028 FFCore.do_tracenl();
37029 break;
37030
37031 case TRACE4:
37032 2 FFCore.do_cleartrace();
37033 2 break;
37034
37035 case TRACE5:
37036 1 FFCore.do_tracetobase();
37037 1 break;
37038
37039 case TRACE6:
37040 384 FFCore.do_tracestring();
37041 384 break;
37042
37043 case PRINTFV:
37044 287 FFCore.do_printf(true, false);
37045 287 break;
37046 case SPRINTFV:
37047 6883 FFCore.do_sprintf(true, false);
37048 6883 break;
37049
37050 case PRINTFVARG:
37051 3319 FFCore.do_printf(true, true);
37052 3319 break;
37053 case SPRINTFVARG:
37054 FFCore.do_sprintf(true, true);
37055 break;
37056 case PRINTFA:
37057 FFCore.do_printfarr();
37058 break;
37059 case SPRINTFA:
37060 FFCore.do_printfarr();
37061 break;
37062 case ARRAYPUSH:
37063 {
37064 auto ptr = SH::read_stack(ri->sp + 2) / 10000;
37065 auto val = SH::read_stack(ri->sp + 1);
37066 auto indx = SH::read_stack(ri->sp + 0) / 10000;
37067 ArrayManager am(ptr);
37068 ri->d[rEXP1] = am.push(val,indx) ? 10000 : 0;
37069 break;
37070 }
37071 case ARRAYPOP:
37072 {
37073 auto ptr = SH::read_stack(ri->sp + 1) / 10000;
37074 auto indx = SH::read_stack(ri->sp + 0) / 10000;
37075 ArrayManager am(ptr);
37076 ri->d[rEXP1] = am.pop(indx);
37077 break;
37078 }
37079
37080 case BREAKPOINT:
37081 if( zasm_debugger )
37082 {
37083 FFCore.do_breakpoint();
37084 }
37085 break;
37086
37087 case WARP:
37088 do_warp(true);
37089 break;
37090
37091 case WARPR:
37092 79 do_warp(false);
37093 79 break;
37094
37095 case PITWARP:
37096 do_pitwarp(true);
37097 break;
37098
37099 case PITWARPR:
37100 126 do_pitwarp(false);
37101 126 break;
37102
37103 case BREAKSHIELD:
37104 do_breakshield();
37105 break;
37106
37107 case SELECTAWPNV:
37108 do_selectweapon(true, 1);
37109 break;
37110
37111 case SELECTAWPNR:
37112 5580 do_selectweapon(false, 1);
37113 5580 break;
37114
37115 case SELECTBWPNV:
37116 do_selectweapon(true, 0);
37117 break;
37118
37119 case SELECTBWPNR:
37120 5268 do_selectweapon(false, 0);
37121 5268 break;
37122
37123 case SELECTXWPNR:
37124 do_selectweapon(false, 2);
37125 break;
37126
37127 case SELECTYWPNR:
37128 do_selectweapon(false, 3);
37129 break;
37130
37131 case PLAYSOUNDR:
37132 170875 do_sfx(false);
37133 170875 break;
37134
37135 case PLAYSOUNDV:
37136 do_sfx(true);
37137 break;
37138
37139 case ADJUSTSFXVOLUMER: FFCore.do_adjustsfxvolume(false); break;
37140 case ADJUSTSFXVOLUMEV: FFCore.do_adjustsfxvolume(true); break;
37141 case ADJUSTVOLUMER: FFCore.do_adjustvolume(false); break;
37142 case ADJUSTVOLUMEV: FFCore.do_adjustvolume(true); break;
37143
37144 case TRIGGERSECRETR:
37145 FFScript::do_triggersecret(false);
37146 break;
37147
37148 case TRIGGERSECRETV:
37149 FFScript::do_triggersecret(true);
37150 break;
37151
37152 case PLAYMIDIR:
37153 63813 do_midi(false);
37154 63813 break;
37155
37156 case PLAYMIDIV:
37157 do_midi(true);
37158 break;
37159
37160 case PLAYENHMUSIC:
37161 79 do_enh_music(false);
37162 79 break;
37163
37164 case GETMUSICFILE:
37165 100 do_get_enh_music_filename(false);
37166 100 break;
37167
37168 case GETMUSICTRACK:
37169 5 do_get_enh_music_track(false);
37170 5 break;
37171
37172 case SETDMAPENHMUSIC:
37173 3750 do_set_dmap_enh_music(false);
37174 3750 break;
37175
37176 // Audio->
37177
37178 case ENDSOUNDR:
37179 stop_sfx(false);
37180 break;
37181
37182 case ENDSOUNDV:
37183 stop_sfx(true);
37184 break;
37185
37186 case PAUSESOUNDR:
37187 pause_sfx(false);
37188 break;
37189
37190 case PAUSESOUNDV:
37191 pause_sfx(true);
37192 break;
37193
37194 case RESUMESOUNDR:
37195 resume_sfx(false);
37196 break;
37197
37198 case RESUMESOUNDV:
37199 resume_sfx(true);
37200 break;
37201
37202
37203
37204 case PAUSESFX:
37205 {
37206 int32_t sound = ri->d[rINDEX]/10000;
37207 pause_sfx(sound);
37208
37209 }
37210 break;
37211
37212 case RESUMESFX:
37213 {
37214 int32_t sound = ri->d[rINDEX]/10000;
37215 resume_sfx(sound);
37216 }
37217 break;
37218
37219 case ADJUSTSFX:
37220 {
37221 do_sfx_ex(false);
37222 }
37223 break;
37224
37225 case PLAYSOUNDEX:
37226 {
37227 do_sfx_ex(true);
37228 }
37229 break;
37230
37231 case GETSFXCOMPLETION:
37232 {
37233 do_get_sfx_completion();
37234 }
37235 break;
37236
37237 case CONTINUESFX:
37238 {
37239 int32_t sound = ri->d[rINDEX]/10000;
37240 //Backend::sfx->cont_sfx(sound);
37241
37242 //! cont_sfx was not ported to the new back end!!!
37243 // I believe this restarted the loop.
37244 resume_sfx(sound);
37245 //What was the old instruction, again? Did it exist? -Z
37246 //continue_sfx(sound);
37247 }
37248 break;
37249
37250
37251 /*
37252 case STOPITEMSOUND:
37253 void stop_item_sfx(int32_t family)
37254 */
37255
37256 // Note: these have never worked.
37257 case PAUSEMUSIC:
37258 //What was the instruction prior to adding backends?
37259 //! The pauseAll() function pauses sfx, not music, so this instruction is not doing what I intended. -Z
37260 //Check AllOff() -Z
37261 //zcmusic_pause(ZCMUSIC* zcm, int32_t pause); is in zcmusic.h
37262 // midi_paused = true;
37263 //pause_all_sfx();
37264
37265 //Backend::sfx->pauseAll();
37266 break;
37267 case RESUMEMUSIC:
37268 //What was the instruction prior to adding backends?
37269 //Check AllOff() -Z
37270 //resume_all_sfx();
37271 // midi_paused = false;
37272 //Backend::sfx->resumeAll();
37273 break;
37274
37275 //!!! typecasting
37276 case LWPNARRPTR:
37277 case EWPNARRPTR:
37278 case ITEMARRPTR:
37279 case IDATAARRPTR:
37280 case FFCARRPTR:
37281 case BOOLARRPTR:
37282 case NPCARRPTR:
37283
37284 case LWPNARRPTR2:
37285 case EWPNARRPTR2:
37286 case ITEMARRPTR2:
37287 case IDATAARRPTR2:
37288 case FFCARRPTR2:
37289 case BOOLARRPTR2:
37290 case NPCARRPTR2:
37291 FFScript::do_typedpointer_typecast(false);
37292 break;
37293
37294 case MSGSTRR:
37295 173 do_message(false);
37296 173 break;
37297
37298 case MSGSTRV:
37299 do_message(true);
37300 break;
37301
37302 case ITEMNAME:
37303 2567 do_getitemname();
37304 2567 break;
37305
37306 case NPCNAME:
37307 do_getnpcname();
37308 break;
37309
37310 case NPCDATAGETNAME:
37311 FFCore.do_getnpcdata_getname();
37312 break;
37313
37314 case GETSAVENAME:
37315 10 do_getsavename();
37316 10 break;
37317
37318 case SETSAVENAME:
37319 do_setsavename();
37320 break;
37321
37322 case GETMESSAGE:
37323 3666 do_getmessage(false);
37324 3666 break;
37325 case SETMESSAGE:
37326 do_setmessage(false);
37327 break;
37328
37329 case GETDMAPNAME:
37330 do_getdmapname(false);
37331 break;
37332
37333 case GETDMAPTITLE:
37334 do_getdmaptitle(false);
37335 break;
37336
37337 case GETDMAPINTRO:
37338 do_getdmapintro(false);
37339 break;
37340
37341 case SETDMAPNAME:
37342 do_setdmapname(false);
37343 break;
37344
37345 case SETDMAPTITLE:
37346 do_setdmaptitle(false);
37347 break;
37348
37349 case SETDMAPINTRO:
37350 do_setdmapintro(false);
37351 break;
37352
37353 case LOADLWEAPONR:
37354 1201098 do_loadlweapon(false);
37355 1201098 break;
37356
37357 case LOADLWEAPONV:
37358 do_loadlweapon(true);
37359 break;
37360
37361 case LOADEWEAPONR:
37362 2753647 do_loadeweapon(false);
37363 2753647 break;
37364
37365 case LOADEWEAPONV:
37366 do_loadeweapon(true);
37367 break;
37368
37369 case LOADITEMR:
37370 136832 do_loaditem(false);
37371 136832 break;
37372
37373 case LOADITEMV:
37374 do_loaditem(true);
37375 break;
37376
37377 case LOADITEMDATAR:
37378 55814 do_loaditemdata(false);
37379 55814 break;
37380
37381 //New Datatypes
37382 case LOADSHOPR:
37383 FFScript::do_loadshopdata(false);
37384 break;
37385 case LOADSHOPV:
37386 FFScript::do_loadshopdata(true);
37387 break;
37388
37389 case LOADINFOSHOPR:
37390 FFScript::do_loadinfoshopdata(false);
37391 break;
37392 case LOADINFOSHOPV:
37393 FFScript::do_loadinfoshopdata(true);
37394 break;
37395 case LOADNPCDATAR:
37396 FFScript::do_loadnpcdata(false);
37397 break;
37398 case LOADNPCDATAV:
37399 FFScript::do_loadnpcdata(true);
37400 break;
37401
37402 case LOADCOMBODATAR:
37403 25412 FFScript::do_loadcombodata(false);
37404 25412 break;
37405 case LOADCOMBODATAV:
37406 FFScript::do_loadcombodata(true);
37407 break;
37408
37409 case LOADMAPDATAR:
37410 FFScript::do_loadmapdata(false);
37411 break;
37412 case LOADMAPDATAV:
37413 FFScript::do_loadmapdata(true);
37414 break;
37415 case LOADTMPSCR:
37416 403497 FFScript::do_loadmapdata_tempscr(false);
37417 403497 break;
37418 case LOADSCROLLSCR:
37419 177544 FFScript::do_loadmapdata_scrollscr(false);
37420 177544 break;
37421
37422 case LOADSPRITEDATAR:
37423 FFScript::do_loadspritedata(false);
37424 break;
37425 case LOADSPRITEDATAV:
37426 FFScript::do_loadspritedata(true);
37427 break;
37428
37429 case LOADSCREENDATAR:
37430 FFScript::do_loadscreendata(false);
37431 break;
37432 case LOADSCREENDATAV:
37433 FFScript::do_loadscreendata(true);
37434 break;
37435
37436 case LOADBITMAPDATAR:
37437 FFScript::do_loadbitmapid(false);
37438 break;
37439
37440
37441 case LOADBITMAPDATAV:
37442 FFScript::do_loadbitmapid(true);
37443 break;
37444
37445 //functions
37446 case LOADDMAPDATAR: //command
37447 756866 FFScript::do_loaddmapdata(false); break;
37448 case LOADDMAPDATAV: //command
37449 FFScript::do_loaddmapdata(true); break;
37450 case LOADSUBDATARV:
37451 FFScript::do_load_subscreendata(false, true); break;
37452 case SWAPSUBSCREENV:
37453 {
37454 auto ty = sarg1/10000;
37455 std::vector<ZCSubscreen>* vec = nullptr;
37456 switch(ty)
37457 {
37458 case sstACTIVE:
37459 vec = &subscreens_active;
37460 break;
37461 case sstPASSIVE:
37462 vec = &subscreens_passive;
37463 break;
37464 case sstOVERLAY:
37465 vec = &subscreens_overlay;
37466 break;
37467 default:
37468 Z_scripterrlog("Invalid Subscreen Type passed to ???: %d\n", ty);
37469 break;
37470 }
37471 if(vec)
37472 {
37473 auto& v = *vec;
37474 int p1 = SH::read_stack(ri->sp+1);
37475 int p2 = SH::read_stack(ri->sp+0);
37476 if(unsigned(p1) >= v.size())
37477 Z_scripterrlog("Invalid susbcr index '%d' passed to subscreendata->Swap*Pages()\n", p1);
37478 else if(unsigned(p2) >= v.size())
37479 Z_scripterrlog("Invalid susbcr index '%d' passed to subscreendata->Swap*Pages()\n", p2);
37480 else zc_swap(v[p1],v[p2]);
37481 }
37482 break;
37483 }
37484 case LOADDIRECTORYR:
37485 FFCore.do_loaddirectory(); break;
37486 case LOADSTACK:
37487 FFCore.do_loadstack(); break;
37488 case CREATEPALDATA:
37489 FFCore.do_create_paldata(); break;
37490 case CREATEPALDATACLR:
37491 FFCore.do_create_paldata_clr(); break;
37492 case MIXCLR:
37493 FFCore.do_mix_clr(); break;
37494 case CREATERGBHEX:
37495 FFCore.do_create_rgb_hex(); break;
37496 case CREATERGB:
37497 FFCore.do_create_rgb(); break;
37498 case CONVERTFROMRGB:
37499 FFCore.do_convert_from_rgb(); break;
37500 case CONVERTTORGB:
37501 FFCore.do_convert_to_rgb(); break;
37502 case PALDATALOADLEVEL:
37503 FFCore.do_paldata_load_level(); break;
37504 case PALDATALOADSPRITE:
37505 FFCore.do_paldata_load_sprite(); break;
37506 case PALDATALOADMAIN:
37507 FFCore.do_paldata_load_main(); break;
37508 case PALDATALOADCYCLE:
37509 FFCore.do_paldata_load_cycle(); break;
37510 case PALDATALOADBITMAP:
37511 FFCore.do_paldata_load_bitmap(); break;
37512 case PALDATAWRITELEVEL:
37513 FFCore.do_paldata_write_level(); break;
37514 case PALDATAWRITELEVELCS:
37515 FFCore.do_paldata_write_levelcset(); break;
37516 case PALDATAWRITESPRITE:
37517 FFCore.do_paldata_write_sprite(); break;
37518 case PALDATAWRITESPRITECS:
37519 FFCore.do_paldata_write_spritecset(); break;
37520 case PALDATAWRITEMAIN:
37521 FFCore.do_paldata_write_main(); break;
37522 case PALDATAWRITEMAINCS:
37523 FFCore.do_paldata_write_maincset(); break;
37524 case PALDATAWRITECYCLE:
37525 FFCore.do_paldata_write_cycle(); break;
37526 case PALDATAWRITECYCLECS:
37527 FFCore.do_paldata_write_cyclecset(); break;
37528 case PALDATAVALIDCLR:
37529 FFCore.do_paldata_colorvalid(); break;
37530 case PALDATACLEARCLR:
37531 FFCore.do_paldata_clearcolor(); break;
37532 case PALDATACLEARCSET:
37533 FFCore.do_paldata_clearcset(); break;
37534 case PALDATAMIX:
37535 FFCore.do_paldata_mix(); break;
37536 case PALDATAMIXCS:
37537 FFCore.do_paldata_mixcset(); break;
37538 case PALDATACOPY:
37539 FFCore.do_paldata_copy(); break;
37540 case PALDATACOPYCSET:
37541 FFCore.do_paldata_copycset(); break;
37542 case PALDATAFREE:
37543 if (user_paldata* pd = checkPalData(ri->paldataref, "Free()", true))
37544 {
37545 pd->clear();
37546 }
37547 break;
37548 case PALDATAOWN:
37549 if (user_paldata* pd = checkPalData(ri->paldataref, "Own()", false))
37550 {
37551 pd->own(type, i);
37552 }
37553 break;
37554 case LOADDROPSETR: //command
37555 FFCore.do_loaddropset(false); break;
37556 case LOADRNG: //command
37557 22 FFCore.do_loadrng(); break;
37558 case LOADBOTTLETYPE: //command
37559 FFCore.do_loadbottle(false); break;
37560 case LOADBSHOPDATA: //command
37561 FFCore.do_loadbottleshop(false); break;
37562
37563 case ITEMGETDISPLAYNAME: //command
37564 item_display_name(false); break;
37565 case ITEMSETDISPLAYNAME: //command
37566 item_display_name(true); break;
37567 case ITEMGETSHOWNNAME: //command
37568 item_shown_name(); break;
37569
37570 case DMAPDATAGETNAMER: //command
37571 FFScript::do_getDMapData_dmapname(false); break;
37572 case DMAPDATAGETNAMEV: //command
37573 FFScript::do_getDMapData_dmapname(true); break;
37574
37575 case DMAPDATASETNAMER: //command
37576 FFScript::do_setDMapData_dmapname(false); break;
37577 case DMAPDATASETNAMEV: //command
37578 FFScript::do_setDMapData_dmapname(true); break;
37579
37580
37581
37582 case DMAPDATAGETTITLER: //command
37583 FFScript::do_getDMapData_dmaptitle(false); break;
37584 case DMAPDATAGETTITLEV: //command
37585 FFScript::do_getDMapData_dmaptitle(true); break;
37586 case DMAPDATASETTITLER: //command
37587 FFScript::do_setDMapData_dmaptitle(false); break;
37588 case DMAPDATASETTITLEV: //command
37589 FFScript::do_setDMapData_dmaptitle(true); break;
37590
37591
37592 case DMAPDATAGETINTROR: //command
37593 FFScript::do_getDMapData_dmapintro(false); break;
37594 case DMAPDATAGETINTROV: //command
37595 FFScript::do_getDMapData_dmapintro(true); break;
37596 case DMAPDATANSETITROR: //command
37597 FFScript::do_setDMapData_dmapintro(false); break;
37598 case DMAPDATASETINTROV: //command
37599 FFScript::do_setDMapData_dmapintro(true); break;
37600
37601
37602 case DMAPDATAGETMUSICR: //command, string to load a music file
37603 FFScript::do_getDMapData_music(false); break;
37604 case DMAPDATAGETMUSICV: //command, string to load a music file
37605 FFScript::do_getDMapData_music(true); break;
37606 case DMAPDATASETMUSICR: //command, string to load a music file
37607 FFScript::do_setDMapData_music(false); break;
37608 case DMAPDATASETMUSICV: //command, string to load a music file
37609 FFScript::do_setDMapData_music(true); break;
37610
37611 case LOADMESSAGEDATAR: //COMMAND
37612 FFScript::do_loadmessagedata(false);
37613 break;
37614 case LOADMESSAGEDATAV: //COMMAND
37615 FFScript::do_loadmessagedata(false);
37616 break;
37617
37618
37619 case MESSAGEDATASETSTRINGR: //command
37620 FFScript::do_messagedata_setstring(false);
37621 break;
37622 case MESSAGEDATASETSTRINGV: //command
37623 FFScript::do_messagedata_setstring(false);
37624 break;
37625
37626 case MESSAGEDATAGETSTRINGR: //command
37627 FFScript::do_messagedata_getstring(false);
37628 break;
37629 case MESSAGEDATAGETSTRINGV: //command
37630 FFScript::do_messagedata_getstring(false);
37631 break;
37632 case LOADITEMDATAV:
37633 do_loaditemdata(true);
37634 break;
37635
37636 case LOADNPCBYSUID:
37637 12 FFCore.do_loadnpc_by_script_uid(false);
37638 12 break;
37639
37640 case LOADLWEAPONBYSUID:
37641 598 FFCore.do_loadlweapon_by_script_uid(false);
37642 598 break;
37643
37644 case LOADWEAPONCBYSUID:
37645 FFCore.do_loadeweapon_by_script_uid(false);
37646 break;
37647
37648 case LOADNPCR:
37649 15644354 do_loadnpc(false);
37650 15644354 break;
37651
37652 case LOADNPCV:
37653 do_loadnpc(true);
37654 break;
37655
37656 case CREATELWEAPONR:
37657 77262 do_createlweapon(false);
37658 77262 break;
37659
37660 case CREATELWEAPONV:
37661 do_createlweapon(true);
37662 break;
37663
37664 case CREATEEWEAPONR:
37665 131917 do_createeweapon(false);
37666 131917 break;
37667
37668 case CREATEEWEAPONV:
37669 do_createeweapon(true);
37670 break;
37671
37672 case CREATEITEMR:
37673 21343 do_createitem(false);
37674 21343 break;
37675
37676 case CREATEITEMV:
37677 do_createitem(true);
37678 break;
37679
37680 case CREATENPCR:
37681 2363 do_createnpc(false);
37682 2363 break;
37683
37684 case CREATENPCV:
37685 do_createnpc(true);
37686 break;
37687
37688 case ISVALIDARRAY:
37689 4 do_isvalidarray();
37690 4 break;
37691
37692 case ISVALIDITEM:
37693 27033 do_isvaliditem();
37694 27033 break;
37695
37696 case ISVALIDBITMAP:
37697 FFCore.do_isvalidbitmap();
37698 break;
37699
37700 case ISALLOCATEDBITMAP:
37701 42 FFCore.do_isallocatedbitmap();
37702 42 break;
37703
37704 case ISVALIDNPC:
37705 6266198 do_isvalidnpc();
37706 6266198 break;
37707
37708 case ISVALIDLWPN:
37709 593592 do_isvalidlwpn();
37710 593592 break;
37711
37712 case ISVALIDEWPN:
37713 122622 do_isvalidewpn();
37714 122622 break;
37715
37716 case LWPNMAKEANGULAR:
37717 do_lwpnmakeangular();
37718 break;
37719
37720 case EWPNMAKEANGULAR:
37721 do_ewpnmakeangular();
37722 break;
37723
37724 case LWPNMAKEDIRECTIONAL:
37725 do_lwpnmakedirectional();
37726 break;
37727
37728 case EWPNMAKEDIRECTIONAL:
37729 do_ewpnmakedirectional();
37730 break;
37731
37732 case LWPNUSESPRITER:
37733 15079 do_lwpnusesprite(false);
37734 15079 break;
37735
37736 case LWPNUSESPRITEV:
37737 do_lwpnusesprite(true);
37738 break;
37739
37740 case EWPNUSESPRITER:
37741 132144 do_ewpnusesprite(false);
37742 132144 break;
37743
37744 case EWPNUSESPRITEV:
37745 do_ewpnusesprite(true);
37746 break;
37747
37748 case CLEARSPRITESR:
37749 do_clearsprites(false);
37750 break;
37751
37752 case CLEARSPRITESV:
37753 do_clearsprites(true);
37754 break;
37755
37756 case ISSOLID:
37757 16271098 do_issolid();
37758 16271098 break;
37759
37760 case MAPDATAISSOLID:
37761 do_mapdataissolid();
37762 break;
37763
37764 case MAPDATAISSOLIDLYR:
37765 do_mapdataissolid_layer();
37766 break;
37767
37768 case ISSOLIDLAYER:
37769 do_issolid_layer();
37770 break;
37771
37772 case SETSIDEWARP:
37773 249 do_setsidewarp();
37774 249 break;
37775
37776 case SETTILEWARP:
37777 5 do_settilewarp();
37778 5 break;
37779
37780 case GETSIDEWARPDMAP:
37781 354940 do_getsidewarpdmap(false);
37782 354940 break;
37783
37784 case GETSIDEWARPSCR:
37785 do_getsidewarpscr(false);
37786 break;
37787
37788 case GETSIDEWARPTYPE:
37789 do_getsidewarptype(false);
37790 break;
37791
37792 case GETTILEWARPDMAP:
37793 354943 do_gettilewarpdmap(false);
37794 354943 break;
37795
37796 case GETTILEWARPSCR:
37797 3 do_gettilewarpscr(false);
37798 3 break;
37799
37800 case GETTILEWARPTYPE:
37801 3 do_gettilewarptype(false);
37802 3 break;
37803
37804 case LAYERSCREEN:
37805 12696160 do_layerscreen();
37806 12696160 break;
37807
37808 case LAYERMAP:
37809 16038753 do_layermap();
37810 16038753 break;
37811
37812 case SECRETS:
37813 60 do_triggersecrets();
37814 60 break;
37815
37816 case GETSCREENFLAGS:
37817 do_getscreenflags();
37818 break;
37819
37820 case GETSCREENEFLAGS:
37821 do_getscreeneflags();
37822 break;
37823
37824 case GRAPHICSGETPIXEL:
37825 FFCore.do_graphics_getpixel();
37826 break;
37827 case GRAPHICSCOUNTCOLOR:
37828 FFCore.do_bmpcollision();
37829 break;
37830
37831 case GETSCREENDOOR:
37832 do_getscreendoor();
37833 break;
37834
37835 case GETSCREENENEMY:
37836 do_getscreennpc();
37837 break;
37838
37839 //screendata and mapdata
37840 case SETSCREENENEMY:
37841 { //void SetScreenEnemy(int32_t map, int32_t screen, int32_t index, int32_t value);
37842 int32_t map = (ri->d[rINDEX2] / 10000) - 1;
37843 int32_t scrn = ri->d[rEXP1] / 10000;
37844 int32_t index = ri->d[rINDEX] / 10000;
37845 int32_t nn = ri->d[rEXP2]/10000;
37846
37847 // int32_t x;
37848
37849 // zprint("ri->d[rEXP2] is (%i), trying to use for '%s'\n", nn, "nn");
37850 // zprint("ri->d[rEXP1] is (%i), trying to use for '%s'\n", scrn, "scrn");
37851 // zprint("ri->d[rINDEX2] is (%i), trying to use for '%s'\n", map, "map");
37852 // zprint("ri->d[rINDEX] is (%i), trying to use for '%s'\n", index, "index");
37853
37854 if(BC::checkMapID(map, "Game->SetScreenEnemy(...map...)") != SH::_NoError ||
37855 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenEnemy(...screen...)") != SH::_NoError ||
37856 BC::checkBounds(index, 0, 9, "Game->SetScreenEnemy(...index...)") != SH::_NoError)
37857 return RUNSCRIPT_ERROR;
37858
37859 // if ( BC::checkBounds(nn, 0, 2, "Game->SetScreenEnemy(...enemy...)") != SH::_NoError) x = 1;
37860 // if ( BC::checkBounds(map, 20, 21, "Game->SetScreenEnemy(...map...)") != SH::_NoError) x = 2;
37861 FFScript::set_screenenemy(&TheMaps[map * MAPSCRS + scrn], index, nn);
37862 }
37863 break;
37864
37865 case SETSCREENDOOR:
37866 { //void SetScreenDoor(int32_t map, int32_t screen, int32_t index, int32_t value);
37867 int32_t map = (ri->d[rINDEX2] / 10000) - 1;
37868 int32_t scrn = ri->d[rEXP1] / 10000;
37869 int32_t index = ri->d[rINDEX] / 10000;
37870 int32_t nn = ri->d[rEXP2]/10000;
37871
37872 if(BC::checkMapID(map, "Game->SetScreenDoor(...map...)") != SH::_NoError ||
37873 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenDoor(...screen...)") != SH::_NoError ||
37874 BC::checkBounds(index, 0, 3, "Game->SetScreenDoor(...doorindex...)") != SH::_NoError)
37875 {
37876 return RUNSCRIPT_ERROR; break;
37877 }
37878 else
37879 {
37880 FFScript::set_screendoor(&TheMaps[map * MAPSCRS + scrn], index, nn);
37881 break;
37882 }
37883
37884 }
37885
37886 case GETSCREENLAYOP:
37887 do_getscreenLayerOpacity();
37888 break;
37889 case GETSCREENSECCMB:
37890 do_getscreenSecretCombo();
37891 break;
37892 case GETSCREENSECCST:
37893 do_getscreenSecretCSet();
37894 break;
37895 case GETSCREENSECFLG:
37896 do_getscreenSecretFlag();
37897 break;
37898 case GETSCREENLAYMAP:
37899 do_getscreenLayerMap();
37900 break;
37901 case GETSCREENLAYSCR:
37902 do_getscreenLayerscreen();
37903 break;
37904 case GETSCREENPATH:
37905 do_getscreenPath();
37906 break;
37907 case GETSCREENWARPRX:
37908 do_getscreenWarpReturnX();
37909 break;
37910 case GETSCREENWARPRY:
37911 do_getscreenWarpReturnY();
37912 break;
37913
37914 case COMBOTILE:
37915 2564 do_combotile(false);
37916 2564 break;
37917
37918 case DRAWLIGHT_CIRCLE:
37919 {
37920 static const int ARGS = 7;
37921 zfix cx = zslongToFix(SH::read_stack(ri->sp + (ARGS-1)));
37922 zfix cy = zslongToFix(SH::read_stack(ri->sp + (ARGS-2)));
37923 int radius = SH::read_stack(ri->sp + (ARGS-3));
37924 int transp_rad = SH::read_stack(ri->sp + (ARGS-4));
37925 int dith_rad = SH::read_stack(ri->sp + (ARGS-5));
37926 int dith_type = SH::read_stack(ri->sp + (ARGS-6));
37927 int dith_arg = SH::read_stack(ri->sp + (ARGS-7));
37928 if(radius >= 0) radius /= 10000;
37929 else radius = game->get_light_rad();
37930 if(!radius) break;
37931 if(transp_rad >= 0) transp_rad /= 10000;
37932 if(dith_rad >= 0) dith_rad /= 10000;
37933 if(dith_type >= 0) dith_type /= 10000;
37934 if(dith_arg >= 0) dith_arg /= 10000;
37935
37936 int32_t scrolldir = FFCore.ScrollingData[SCROLLDATA_DIR];
37937 int32_t scrollxoffs = 0, scrollyoffs = 0;
37938 switch(scrolldir)
37939 {
37940 case up:
37941 scrollyoffs = -176;
37942 break;
37943 case down:
37944 scrollyoffs = 176;
37945 break;
37946 case left:
37947 scrollxoffs = -256;
37948 break;
37949 case right:
37950 scrollxoffs = 256;
37951 break;
37952 }
37953
37954 doDarkroomCircle(cx,cy,radius,darkscr_bmp_curscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
37955 doDarkroomCircle(cx+scrollxoffs,cy+scrollyoffs,radius,darkscr_bmp_scrollscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
37956 break;
37957 }
37958 case DRAWLIGHT_SQUARE:
37959 {
37960 static const int ARGS = 7;
37961 zfix cx = zslongToFix(SH::read_stack(ri->sp + (ARGS-1)));
37962 zfix cy = zslongToFix(SH::read_stack(ri->sp + (ARGS-2)));
37963 int radius = SH::read_stack(ri->sp + (ARGS-3));
37964 int transp_rad = SH::read_stack(ri->sp + (ARGS-4));
37965 int dith_rad = SH::read_stack(ri->sp + (ARGS-5));
37966 int dith_type = SH::read_stack(ri->sp + (ARGS-6));
37967 int dith_arg = SH::read_stack(ri->sp + (ARGS-7));
37968 if(radius >= 0) radius /= 10000;
37969 else radius = game->get_light_rad();
37970 if(!radius) break;
37971 if(transp_rad >= 0) transp_rad /= 10000;
37972 if(dith_rad >= 0) dith_rad /= 10000;
37973 if(dith_type >= 0) dith_type /= 10000;
37974 if(dith_arg >= 0) dith_arg /= 10000;
37975
37976 int32_t scrolldir = FFCore.ScrollingData[SCROLLDATA_DIR];
37977 int32_t scrollxoffs = 0, scrollyoffs = 0;
37978 switch(scrolldir)
37979 {
37980 case up:
37981 scrollyoffs = -176;
37982 break;
37983 case down:
37984 scrollyoffs = 176;
37985 break;
37986 case left:
37987 scrollxoffs = -256;
37988 break;
37989 case right:
37990 scrollxoffs = 256;
37991 break;
37992 }
37993
37994 doDarkroomSquare(cx,cy,radius,darkscr_bmp_curscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
37995 doDarkroomSquare(cx+scrollxoffs,cy+scrollyoffs,radius,darkscr_bmp_scrollscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
37996 break;
37997 }
37998 case DRAWLIGHT_CONE:
37999 {
38000 static const int ARGS = 8;
38001 zfix cx = zslongToFix(SH::read_stack(ri->sp + (ARGS-1)));
38002 zfix cy = zslongToFix(SH::read_stack(ri->sp + (ARGS-2)));
38003 int dir = SH::read_stack(ri->sp + (ARGS-3)) / 10000;
38004 int radius = SH::read_stack(ri->sp + (ARGS-4));
38005 int transp_rad = SH::read_stack(ri->sp + (ARGS-5));
38006 int dith_rad = SH::read_stack(ri->sp + (ARGS-6));
38007 int dith_type = SH::read_stack(ri->sp + (ARGS-7));
38008 int dith_arg = SH::read_stack(ri->sp + (ARGS-8));
38009 if(radius >= 0) radius /= 10000;
38010 else radius = game->get_light_rad()*2;
38011 if(!radius) break;
38012 if(dir < 0) break;
38013 else dir = NORMAL_DIR(dir);
38014 if(transp_rad >= 0) transp_rad /= 10000;
38015 if(dith_rad >= 0) dith_rad /= 10000;
38016 if(dith_type >= 0) dith_type /= 10000;
38017 if(dith_arg >= 0) dith_arg /= 10000;
38018
38019 int32_t scrolldir = FFCore.ScrollingData[SCROLLDATA_DIR];
38020 int32_t scrollxoffs = 0, scrollyoffs = 0;
38021 switch(scrolldir)
38022 {
38023 case up:
38024 scrollyoffs = -176;
38025 break;
38026 case down:
38027 scrollyoffs = 176;
38028 break;
38029 case left:
38030 scrollxoffs = -256;
38031 break;
38032 case right:
38033 scrollxoffs = 256;
38034 break;
38035 }
38036
38037 doDarkroomCone(cx,cy,radius,dir,darkscr_bmp_curscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
38038 doDarkroomCone(cx+scrollxoffs,cy+scrollyoffs,radius,dir,darkscr_bmp_scrollscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
38039 break;
38040 }
38041
38042 case RECTR:
38043 case CIRCLER:
38044 case ARCR:
38045 case ELLIPSER:
38046 case LINER:
38047 case PUTPIXELR:
38048 case PIXELARRAYR:
38049 case TILEARRAYR:
38050 case LINESARRAY:
38051 case COMBOARRAYR:
38052 case DRAWTILER:
38053 case DRAWTILECLOAKEDR:
38054 case DRAWCOMBOR:
38055 case DRAWCOMBOCLOAKEDR:
38056 case DRAWCHARR:
38057 case DRAWINTR:
38058 case QUADR:
38059 case TRIANGLER:
38060 case QUAD3DR:
38061 case TRIANGLE3DR:
38062 case FASTTILER:
38063 case FASTCOMBOR:
38064 case DRAWSTRINGR:
38065 case DRAWSTRINGR2:
38066 case BMPDRAWSTRINGR2:
38067 case SPLINER:
38068 case BITMAPR:
38069 case BITMAPEXR:
38070 case DRAWLAYERR:
38071 case DRAWSCREENR:
38072 case POLYGONR:
38073 case FRAMER:
38074 37306789 do_drawing_command(scommand);
38075 37306789 break;
38076
38077 case BMPRECTR:
38078 case BMPCIRCLER:
38079 case BMPARCR:
38080 case BMPELLIPSER:
38081 case BMPLINER:
38082 case BMPSPLINER:
38083 case BMPPUTPIXELR:
38084 case BMPDRAWTILER:
38085 case BMPDRAWTILECLOAKEDR:
38086 case BMPDRAWCOMBOR:
38087 case BMPDRAWCOMBOCLOAKEDR:
38088 case BMPFASTTILER:
38089 case BMPFASTCOMBOR:
38090 case BMPDRAWCHARR:
38091 case BMPDRAWINTR:
38092 case BMPDRAWSTRINGR:
38093 case BMPQUADR:
38094 case BMPQUAD3DR:
38095 case BMPTRIANGLER:
38096 case BMPTRIANGLE3DR:
38097 case BMPPOLYGONR:
38098 case BMPDRAWLAYERR:
38099 case BMPDRAWLAYERSOLIDR:
38100 case BMPDRAWLAYERCFLAGR:
38101 case BMPDRAWLAYERCTYPER:
38102 case BMPDRAWLAYERCIFLAGR:
38103 case BMPDRAWLAYERSOLIDITYR:
38104 case BMPDRAWSCREENR:
38105 case BMPDRAWSCREENSOLIDR:
38106 case BMPDRAWSCREENSOLID2R:
38107 case BMPDRAWSCREENCOMBOFR:
38108 case BMPDRAWSCREENCOMBOIR:
38109 case BMPDRAWSCREENCOMBOTR:
38110 case BITMAPGETPIXEL:
38111 case BMPBLIT:
38112 case BMPBLITTO:
38113 case BMPMODE7:
38114 case WRITEBITMAP:
38115 case CLEARBITMAP:
38116 case BITMAPCLEARTOCOLOR:
38117 case BMPFRAMER:
38118 case BMPWRITETILE:
38119 case BMPDITHER:
38120 case BMPREPLCOLOR:
38121 case BMPSHIFTCOLOR:
38122 case BMPMASKDRAW:
38123 case BMPMASKDRAW2:
38124 case BMPMASKDRAW3:
38125 case BMPMASKBLIT:
38126 case BMPMASKBLIT2:
38127 case BMPMASKBLIT3:
38128 576754 do_drawing_command(scommand);
38129 576754 break;
38130 case READBITMAP:
38131 {
38132 int32_t bitref = SH::read_stack(ri->sp+2);
38133 if(user_bitmap* b = checkBitmap(bitref,"Read()",false,true))
38134 do_drawing_command(scommand);
38135 else //If the pointer isn't allocated, attempt to allocate it first
38136 {
38137 bitref = FFCore.get_free_bitmap();
38138 ri->d[rEXP2] = bitref; //Return to ptr
38139 if(bitref) SH::write_stack(ri->sp+2,bitref); //Write the ref, for the drawing command to read
38140 else break; //No ref allocated; don't enqueue the drawing command.
38141 do_drawing_command(scommand);
38142 }
38143 break;
38144 }
38145 case REGENERATEBITMAP:
38146 {
38147 26528 ri->d[rEXP2] = SH::read_stack(ri->sp+3);
38148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26528 times.
26528 if(user_bitmap* b = checkBitmap(ri->d[rEXP2],"Create()",false,true))
38149 26528 do_drawing_command(scommand);
38150 else //If the pointer isn't allocated
38151 {
38152 int32_t w = SH::read_stack(ri->sp) / 10000;
38153 int32_t h = SH::read_stack(ri->sp+1) / 10000;
38154 if ( get_qr(qr_OLDCREATEBITMAP_ARGS) )
38155 {
38156 //flip height and width
38157 h = h ^ w;
38158 w = h ^ w;
38159 h = h ^ w;
38160 }
38161
38162 ri->d[rEXP2] = FFCore.create_user_bitmap_ex(h,w,8); //Return to ptr
38163 }
38164 26528 break;
38165 }
38166
38167 case BITMAPFREE:
38168 {
38169 FFCore.do_deallocate_bitmap();
38170 break;
38171 }
38172
38173 case BITMAPOWN:
38174 {
38175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if(FFCore.isSystemBitref(ri->bitmapref))
38176 break; //Don't attempt to own system bitmaps!
38177 146 user_bitmap* b = checkBitmap(ri->bitmapref, "Own()", false);
38178
1/2
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
146 if(b)
38179 {
38180 146 b->own(type, i);
38181 146 }
38182 146 break;
38183 }
38184
38185 case OBJ_OWN_BITMAP:
38186 {
38187 int bmpid = get_register(sarg1);
38188 if(FFCore.isSystemBitref(bmpid))
38189 break; //Don't attempt to own system bitmaps!
38190 user_bitmap* b = checkBitmap(bmpid, nullptr, false);
38191 if(!b) break;
38192 ScriptType own_type = (ScriptType)sarg2;
38193 int32_t own_i = get_own_i(own_type);
38194 b->own(own_type,own_i);
38195 break;
38196 }
38197 case OBJ_OWN_PALDATA:
38198 {
38199 int palid = get_register(sarg1);
38200 user_paldata* pd = checkPalData(palid, nullptr, false);
38201 if(!pd) break;
38202 ScriptType own_type = (ScriptType)sarg2;
38203 int32_t own_i = get_own_i(own_type);
38204 pd->own(own_type,own_i);
38205 break;
38206 }
38207 case OBJ_OWN_FILE:
38208 {
38209 int fileid = get_register(sarg1);
38210 user_file* f = checkFile(fileid, nullptr, false);
38211 if(!f) break;
38212 ScriptType own_type = (ScriptType)sarg2;
38213 int32_t own_i = get_own_i(own_type);
38214 f->own(own_type,own_i);
38215 break;
38216 }
38217 case OBJ_OWN_DIR:
38218 {
38219 int dirid = get_register(sarg1);
38220 user_dir* dr = checkDir(dirid, nullptr, false);
38221 if(!dr) break;
38222 ScriptType own_type = (ScriptType)sarg2;
38223 int32_t own_i = get_own_i(own_type);
38224 dr->own(own_type,own_i);
38225 break;
38226 }
38227 case OBJ_OWN_STACK:
38228 {
38229 int stackid = get_register(sarg1);
38230 user_stack* st = checkStack(stackid, nullptr, false);
38231 if(!st) break;
38232 ScriptType own_type = (ScriptType)sarg2;
38233 int32_t own_i = get_own_i(own_type);
38234 st->own(own_type,own_i);
38235 break;
38236 }
38237 case OBJ_OWN_RNG:
38238 {
38239 int rngid = get_register(sarg1);
38240 user_rng* r = checkRNG(rngid, nullptr, false);
38241 if(!r) break;
38242 ScriptType own_type = (ScriptType)sarg2;
38243 int32_t own_i = get_own_i(own_type);
38244 r->own(own_type,own_i);
38245 break;
38246 }
38247 case OBJ_OWN_CLASS:
38248 {
38249 int classid = get_register(sarg1);
38250 user_object* obj = checkObject(classid, false);
38251 if(!obj) break;
38252 ScriptType own_type = (ScriptType)sarg2;
38253 int32_t own_i = get_own_i(own_type);
38254 obj->own(own_type,own_i);
38255 break;
38256 }
38257 case OBJ_OWN_ARRAY:
38258 {
38259 int arrid = get_register(sarg1)/10000;
38260 ScriptType own_type = (ScriptType)sarg2;
38261 int32_t own_i = get_own_i(own_type);
38262 do_own_array(arrid, own_type, own_i);
38263 break;
38264 }
38265
38266 case COPYTILEVV:
38267 do_copytile(true, true);
38268 break;
38269
38270 case COPYTILEVR:
38271 do_copytile(true, false);
38272 break;
38273
38274 case COPYTILERV:
38275 do_copytile(false, true);
38276 break;
38277
38278 case COPYTILERR:
38279 16962076 do_copytile(false, false);
38280 16962076 break;
38281
38282 case SWAPTILEVV:
38283 do_swaptile(true, true);
38284 break;
38285
38286 case SWAPTILEVR:
38287 do_swaptile(true, false);
38288 break;
38289
38290 case SWAPTILERV:
38291 do_swaptile(false, true);
38292 break;
38293
38294 case SWAPTILERR:
38295 do_swaptile(false, false);
38296 break;
38297
38298 case CLEARTILEV:
38299 do_cleartile(true);
38300 break;
38301
38302 case CLEARTILER:
38303 do_cleartile(false);
38304 break;
38305
38306 case OVERLAYTILEVV:
38307 do_overlaytile(true, true);
38308 break;
38309
38310 case OVERLAYTILEVR:
38311 do_overlaytile(true, false);
38312 break;
38313
38314 case OVERLAYTILERV:
38315 do_overlaytile(false, true);
38316 break;
38317
38318 case OVERLAYTILERR:
38319 57032 do_overlaytile(false, false);
38320 57032 break;
38321
38322 case FLIPROTTILEVV:
38323 do_fliprotatetile(true, true);
38324 break;
38325
38326 case FLIPROTTILEVR:
38327 do_fliprotatetile(true, false);
38328 break;
38329
38330 case FLIPROTTILERV:
38331 do_fliprotatetile(false, true);
38332 break;
38333
38334 case FLIPROTTILERR:
38335 do_fliprotatetile(false, false);
38336 break;
38337
38338 case GETTILEPIXEL:
38339 do_gettilepixel();
38340 break;
38341
38342 case SETTILEPIXEL:
38343 do_settilepixel();
38344 break;
38345
38346 case SHIFTTILEVV:
38347 do_shifttile(true, true);
38348 break;
38349
38350 case SHIFTTILEVR:
38351 do_shifttile(true, false);
38352 break;
38353
38354 case SHIFTTILERV:
38355 do_shifttile(false, true);
38356 break;
38357
38358 case SHIFTTILERR:
38359 do_shifttile(false, false);
38360 break;
38361
38362 case SETRENDERTARGET:
38363 3535588 do_set_rendertarget(true);
38364 3535588 break;
38365
38366 case GAMEEND:
38367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( using_SRAM )
38368 {
38369 Z_scripterrlog("Cannot End Game while reading or writing to SRAM. Aborting End. /n");
38370 break;
38371 }
38372 1 Quit = qQUIT;
38373 1 skipcont = 1;
38374 1 scommand = 0xFFFF;
38375 1 break;
38376 case GAMERELOAD:
38377 if ( using_SRAM )
38378 {
38379 Z_scripterrlog("Cannot Reload Game while reading or writing to SRAM. Aborting Reload. /n");
38380 break;
38381 }
38382 Quit = qRELOAD;
38383 skipcont = 1;
38384 scommand = 0xFFFF;
38385 break;
38386 case GAMESETCUSTOMCURSOR:
38387 {
38388 int32_t bmpptr = SH::read_stack(ri->sp + 4);
38389 int fx = SH::read_stack(ri->sp + 3) / 10000;
38390 int fy = SH::read_stack(ri->sp + 2) / 10000;
38391 bool recolor = SH::read_stack(ri->sp + 1)!=0;
38392 bool scale = SH::read_stack(ri->sp + 0)!=0;
38393 if(user_bitmap* b = checkBitmap(bmpptr,nullptr,true))
38394 {
38395 custom_mouse(b->u_bmp,fx,fy,recolor,scale);
38396 }
38397 break;
38398 }
38399 case CURRENTITEMID:
38400 {
38401 int ity = SH::read_stack(ri->sp + 1) / 10000;
38402 int flags = SH::read_stack(ri->sp + 0) / 10000;
38403 bool checkcost = flags&0x01;
38404 bool checkjinx = flags&0x02;
38405 bool check_bunny = flags&0x04;
38406 ri->d[rEXP1] = current_item_id(ity,checkcost,checkjinx,check_bunny) * 10000;
38407 break;
38408 }
38409
38410 case GAMECONTINUE:
38411 if ( using_SRAM )
38412 {
38413 Z_scripterrlog("Cannot Continue Game while reading or writing to SRAM. Aborting Continue. /n");
38414 break;
38415 }
38416 reset_combo_animations();
38417 reset_combo_animations2();
38418
38419 Quit = qCONT;
38420 skipcont = 1;
38421 //cont_game();
38422 scommand = 0xFFFF;
38423 break;
38424
38425 case GAMESAVEQUIT:
38426 if ( using_SRAM )
38427 {
38428 Z_scripterrlog("Cannot Save Game while reading or writing to SRAM. Aborting Save. /n");
38429 break;
38430 }
38431 Quit = qSAVE;
38432 skipcont = 1;
38433 scommand =0xFFFF;
38434 break;
38435
38436 case GAMESAVECONTINUE:
38437 Quit = qSAVECONT;
38438 skipcont = 1;
38439 scommand =0xFFFF;
38440 break;
38441
38442 case SAVE:
38443
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( using_SRAM )
38444 {
38445 Z_scripterrlog("Cannot Save Game while reading or writing to SRAM. Aborting Save. /n");
38446 break;
38447 }
38448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(scriptCanSave)
38449 {
38450 11 save_game(false);
38451 11 scriptCanSave=false;
38452 11 }
38453 11 break;
38454
38455 case SAVESCREEN:
38456 do_showsavescreen();
38457 break;
38458
38459 case SHOWF6SCREEN:
38460 onTryQuit();
38461 break;
38462
38463 case SAVEQUITSCREEN:
38464 save_game(false, 1);
38465 break;
38466
38467 //Not Implemented
38468 case ELLIPSE2:
38469 case FLOODFILL:
38470 break;
38471
38472 case SETCOLORB:
38473 case SETDEPTHB:
38474 case GETCOLORB:
38475 case GETDEPTHB:
38476 break;
38477
38478 case ENQUEUER:
38479 do_enqueue(false);
38480 break;
38481
38482 case ENQUEUEV:
38483 do_enqueue(true);
38484 break;
38485
38486 case DEQUEUE:
38487 do_dequeue(false);
38488 break;
38489
38490 //Visual Effects
38491 case WAVYIN:
38492 FFScript::do_wavyin();
38493 break;
38494 case WAVYOUT:
38495 FFScript::do_wavyout();
38496 break;
38497 case ZAPIN:
38498 FFScript::do_zapin();
38499 break;
38500 case ZAPOUT:
38501 FFScript::do_zapout();
38502 break;
38503 case OPENWIPE:
38504 {
38505 FFScript::do_openscreen();
38506 break;
38507 }
38508 case CLOSEWIPE:
38509 {
38510 FFScript::do_closescreen();
38511 break;
38512 }
38513 case OPENWIPESHAPE:
38514 {
38515 FFScript::do_openscreenshape();
38516 break;
38517 }
38518 case CLOSEWIPESHAPE:
38519 {
38520 FFScript::do_closescreenshape();
38521 break;
38522 }
38523
38524 //Monochrome
38525 case GREYSCALEON:
38526 setMonochrome(true);
38527 break;
38528 case GREYSCALEOFF:
38529 setMonochrome(false);
38530 break;
38531
38532 case TINT:
38533 {
38534 FFCore.Tint();
38535 break;
38536 }
38537
38538 case CLEARTINT:
38539 {
38540 FFCore.clearTint();
38541 break;
38542 }
38543
38544 case MONOHUE:
38545 {
38546 FFCore.gfxmonohue();
38547 break;
38548 }
38549
38550 case SCREENDOSPAWN:
38551 {
38552 ri->d[rEXP1] = scriptloadenemies() ? 10000 : 0;
38553 break;
38554 }
38555
38556 case SCRTRIGGERCOMBO:
38557 {
38558 int32_t lyr = get_register(sarg1) / 10000;
38559 int32_t pos = get_register(sarg2) / 10000;
38560 set_register(sarg1, do_trigger_combo(lyr,pos) ? 10000 : 0);
38561 break;
38562 }
38563
38564 case SWITCHNPC:
38565 {
38566 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
38567 set_register(sarg1,0);
38568 if(Hero.switchhookclk) break; //Already switching!
38569 if(GuyH::loadNPC(ri->guyref, "npc->Switch()") == SH::_NoError)
38570 {
38571 switching_object = guys.spr(GuyH::getNPCIndex(ri->guyref));
38572 hooked_combopos = -1;
38573 hooked_layerbits = 0;
38574 switching_object->switch_hooked = true;
38575 Hero.doSwitchHook(effect);
38576 set_register(sarg1,10000);
38577 }
38578 break;
38579 }
38580
38581 case SWITCHITM:
38582 {
38583 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
38584 set_register(sarg1,0);
38585 if(Hero.switchhookclk) break; //Already switching!
38586 if(ItemH::loadItem(ri->itemref, "item->Switch()") == SH::_NoError)
38587 {
38588 switching_object = items.spr(ItemH::getItemIndex(ri->itemref));
38589 hooked_combopos = -1;
38590 hooked_layerbits = 0;
38591 switching_object->switch_hooked = true;
38592 Hero.doSwitchHook(effect);
38593 set_register(sarg1,10000);
38594 }
38595 break;
38596 }
38597
38598 case SWITCHLW:
38599 {
38600 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
38601 set_register(sarg1,0);
38602 if(Hero.switchhookclk) break; //Already switching!
38603 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->Switch()") == SH::_NoError)
38604 {
38605 switching_object = Lwpns.spr(LwpnH::getLWeaponIndex(ri->lwpn));
38606 hooked_combopos = -1;
38607 hooked_layerbits = 0;
38608 switching_object->switch_hooked = true;
38609 Hero.doSwitchHook(effect);
38610 set_register(sarg1,10000);
38611 }
38612 break;
38613 }
38614
38615 case SWITCHEW:
38616 {
38617 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
38618 set_register(sarg1,0);
38619 if(Hero.switchhookclk) break; //Already switching!
38620 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->Switch()") == SH::_NoError)
38621 {
38622 switching_object = Ewpns.spr(EwpnH::getEWeaponIndex(ri->lwpn));
38623 hooked_combopos = -1;
38624 hooked_layerbits = 0;
38625 switching_object->switch_hooked = true;
38626 Hero.doSwitchHook(effect);
38627 set_register(sarg1,10000);
38628 }
38629 break;
38630 }
38631
38632 case SWITCHCMB:
38633 {
38634 int32_t pos = get_register(sarg1)/10000;
38635 set_register(sarg1,0);
38636 if(Hero.switchhookclk) break; //Already switching!
38637 if(unsigned(pos) > 176)
38638 break;
38639 switching_object = NULL;
38640 hooked_combopos = pos;
38641 hooked_layerbits = 0;
38642 Hero.doSwitchHook(get_register(sarg2)/10000);
38643 if(!hooked_layerbits) //failed
38644 Hero.reset_hookshot();
38645 else set_register(sarg1,10000); //success return
38646 break;
38647 }
38648
38649 case LINKWARPEXR:
38650 {
38651 16 FFCore.do_warp_ex(false);
38652 16 break;
38653 }
38654
38655 case KILLPLAYER:
38656 {
38657 Hero.kill(get_register(sarg1));
38658 break;
38659 }
38660
38661 case HEROMOVEXY:
38662 {
38663 zfix dx = zslongToFix(SH::read_stack(ri->sp + 4));
38664 zfix dy = zslongToFix(SH::read_stack(ri->sp + 3));
38665 bool kb = SH::read_stack(ri->sp + 2)!=0;
38666 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
38667 bool shove = SH::read_stack(ri->sp + 0)!=0;
38668 ri->d[rEXP1] = Hero.movexy(dx, dy, kb, ign_sv, shove) ? 10000 : 0;
38669 break;
38670 }
38671 case HEROCANMOVEXY:
38672 {
38673 zfix dx = zslongToFix(SH::read_stack(ri->sp + 4));
38674 zfix dy = zslongToFix(SH::read_stack(ri->sp + 3));
38675 bool kb = SH::read_stack(ri->sp + 2)!=0;
38676 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
38677 bool shove = SH::read_stack(ri->sp + 0)!=0;
38678 ri->d[rEXP1] = Hero.can_movexy(dx, dy, kb, ign_sv, shove) ? 10000 : 0;
38679 break;
38680 }
38681 case HEROMOVEATANGLE:
38682 {
38683 zfix degrees = zslongToFix(SH::read_stack(ri->sp + 4));
38684 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
38685 bool kb = SH::read_stack(ri->sp + 2)!=0;
38686 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
38687 bool shove = SH::read_stack(ri->sp + 0)!=0;
38688 ri->d[rEXP1] = Hero.moveAtAngle(degrees, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
38689 break;
38690 }
38691 case HEROCANMOVEATANGLE:
38692 {
38693 zfix degrees = zslongToFix(SH::read_stack(ri->sp + 4));
38694 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
38695 bool kb = SH::read_stack(ri->sp + 2)!=0;
38696 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
38697 bool shove = SH::read_stack(ri->sp + 0)!=0;
38698 ri->d[rEXP1] = Hero.can_moveAtAngle(degrees, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
38699 break;
38700 }
38701 case HEROMOVE:
38702 {
38703 int dir = SH::read_stack(ri->sp + 4)/10000;
38704 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
38705 bool kb = SH::read_stack(ri->sp + 2)!=0;
38706 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
38707 bool shove = SH::read_stack(ri->sp + 0)!=0;
38708 ri->d[rEXP1] = Hero.moveDir(dir, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
38709 break;
38710 }
38711 case HEROCANMOVE:
38712 {
38713 int dir = SH::read_stack(ri->sp + 4)/10000;
38714 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
38715 bool kb = SH::read_stack(ri->sp + 2)!=0;
38716 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
38717 bool shove = SH::read_stack(ri->sp + 0)!=0;
38718 ri->d[rEXP1] = Hero.can_moveDir(dir, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
38719 break;
38720 }
38721 case HEROLIFTRELEASE:
38722 {
38723 if(Hero.lift_wpn)
38724 {
38725 ri->d[rEXP1] = Hero.lift_wpn->getUID();
38726 Lwpns.add(Hero.lift_wpn);
38727 Hero.lift_wpn = nullptr;
38728 }
38729 else ri->d[rEXP1] = 0;
38730 break;
38731 }
38732 case HEROLIFTGRAB:
38733 {
38734 auto lwuid = SH::read_stack(ri->sp + 2);
38735 auto lifttime = SH::read_stack(ri->sp + 1)/10000;
38736 auto liftheight = zslongToFix(SH::read_stack(ri->sp + 0));
38737 if(weapon* wpn = checkLWpn(lwuid,"Hero->Lift()"))
38738 {
38739 Hero.lift(wpn, lifttime, liftheight);
38740 if(Lwpns.find(wpn) > -1)
38741 Lwpns.remove(wpn);
38742 if(type == ScriptType::Lwpn && lwuid == i)
38743 earlyretval = RUNSCRIPT_SELFREMOVE;
38744 }
38745 break;
38746 }
38747 case LOADPORTAL:
38748 {
38749 auto val = get_register(sarg1)/10000;
38750 if(val != -1)
38751 {
38752 portal* prt = (portal*)portals.spr(val);
38753 if(prt)
38754 val = prt->getUID();
38755 else
38756 {
38757 Z_scripterrlog("Tried to load invalid portal index '%d'\n", val);
38758 val = 0;
38759 }
38760 }
38761 ri->portalref = ri->d[rEXP1] = val;
38762 break;
38763 }
38764 case CREATEPORTAL:
38765 {
38766 portal* p = new portal();
38767 if(portals.add(p))
38768 ri->portalref = ri->d[rEXP1] = p->getUID();
38769 else
38770 {
38771 ri->portalref = ri->d[rEXP1] = 0;
38772 Z_scripterrlog("Unable to create new portal! Limit reached!\n");
38773 }
38774 break;
38775 }
38776 case LOADSAVPORTAL:
38777 {
38778 auto val = get_register(sarg1)/10000;
38779 savedportal* prt = checkSavedPortal(val,"Game->LoadSavedPortal");
38780 ri->saveportalref = ri->d[rEXP1] = prt ? val : 0;
38781 break;
38782 }
38783 case CREATESAVPORTAL:
38784 {
38785 if(game->user_portals.size() >= MAX_SAVED_PORTALS)
38786 {
38787 ri->saveportalref = ri->d[rEXP1] = 0;
38788 Z_scripterrlog("Cannot create any more Saved Portals! Remove some first!\n");
38789 break;
38790 }
38791 savedportal& ref = game->user_portals.emplace_back();
38792 ri->saveportalref = ri->d[rEXP1] = ref.getUID();
38793 break;
38794 }
38795 case PORTALREMOVE:
38796 {
38797 if(portal* p = checkPortal(ri->portalref, "Remove", true))
38798 {
38799 if(p == &mirror_portal)
38800 p->clear();
38801 else
38802 {
38803 auto id = portals.find(p);
38804 if(id > -1)
38805 portals.del(id,true);
38806 }
38807 }
38808 break;
38809 }
38810 case PORTALUSESPRITE:
38811 do_portalusesprite();
38812 break;
38813 case SAVEDPORTALREMOVE:
38814 {
38815 if(savedportal* sp = checkSavedPortal(ri->saveportalref, "Remove", true))
38816 {
38817 if(sp == &(game->saved_mirror_portal))
38818 sp->clear();
38819 else
38820 {
38821 //ensure all pointers to the object are cleared before deleting
38822 portals.forEach([&](sprite& spr)
38823 {
38824 portal* tmp = (portal*)&spr;
38825 if(sp->getUID() == tmp->saved_data)
38826 {
38827 tmp->saved_data = 0;
38828 }
38829 return false;
38830 });
38831 //delete the savedportal object from the vector
38832 for(auto it = game->user_portals.begin();
38833 it != game->user_portals.end();)
38834 {
38835 savedportal& tmp = *it;
38836 if(sp == &tmp)
38837 {
38838 game->user_portals.erase(it);
38839 break;
38840 }
38841 else ++it;
38842 }
38843 }
38844 }
38845 break;
38846 }
38847 case SAVEDPORTALGENERATE:
38848 {
38849 auto retval = 0;
38850 if(savedportal* sp = checkSavedPortal(ri->saveportalref, "Generate"))
38851 {
38852 retval = getPortalFromSaved(sp);
38853 if(!retval)
38854 {
38855 if(portal* p = loadportal(*sp))
38856 if(portals.add(p))
38857 retval = p->getUID();
38858 }
38859 }
38860 ri->d[rEXP1] = retval;
38861 break;
38862 }
38863
38864 case LINKEXPLODER:
38865 {
38866 int32_t mode = get_register(sarg1) / 10000;
38867 if ( (unsigned) mode > 2 )
38868 {
38869 Z_scripterrlog("Invalid mode (%d) passed to Player->Explode(int32_t mode)\n",mode);
38870 }
38871 else Hero.explode(mode);
38872 break;
38873 }
38874 case NPCEXPLODER:
38875 {
38876
38877 int32_t mode = get_register(sarg1) / 10000;
38878 al_trace("Called npc->Explode(%d), for enemy index %u\n", mode, ri->guyref);
38879 if ( (unsigned) mode > 2 )
38880 {
38881 Z_scripterrlog("Invalid mode (%d) passed to npc->Explode(int32_t mode)\n",mode);
38882 }
38883 else
38884 {
38885 if(GuyH::loadNPC(ri->guyref, "npc->Explode()") == SH::_NoError)
38886 {
38887 al_trace("npc->Explode() is loading the npc into a pointer.\n");
38888 //enemy *e = (enemy*)guys.spr(ri->guyref);
38889 al_trace("npc->Explode() is calling enemy::explode.\n");
38890 //(enemy *) guys.explode(eid);
38891 //e->explode(mode);
38892 //enemy *en=GuyH::getNPC();
38893 //en->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
38894 guys.spr(GuyH::getNPCIndex(ri->guyref))->explode(mode);
38895 }
38896 }
38897 break;
38898 }
38899
38900 case ITEMEXPLODER:
38901 {
38902
38903 int32_t mode = get_register(sarg1) / 10000;
38904 al_trace("Called item->Explode(%d), for item index %u\n", mode, ri->itemref);
38905 if ( (unsigned) mode > 2 )
38906 {
38907 Z_scripterrlog("Invalid mode (%d) passed to item->Explode(int32_t mode)\n",mode);
38908 }
38909 else
38910 {
38911 if(ItemH::loadItem(ri->itemref, "item->Explode()") == SH::_NoError)
38912 {
38913 items.spr(ItemH::getItemIndex(ri->itemref))->explode(mode);
38914 }
38915 }
38916 break;
38917 }
38918 case LWEAPONEXPLODER:
38919 {
38920
38921 int32_t mode = get_register(sarg1) / 10000;
38922 al_trace("Called lweapon->Explode(%d), for lweapon index %u\n", mode, ri->lwpn);
38923 if ( (unsigned) mode > 2 )
38924 {
38925 Z_scripterrlog("Invalid mode (%d) passed to lweapon->Explode(int32_t mode)\n",mode);
38926 }
38927 else
38928 {
38929 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->Explode()") == SH::_NoError)
38930 {
38931 Lwpns.spr(LwpnH::getLWeaponIndex(ri->lwpn))->explode(mode);
38932 }
38933 }
38934 break;
38935 }
38936 case EWEAPONEXPLODER:
38937 {
38938
38939 int32_t mode = get_register(sarg1) / 10000;
38940 al_trace("Called eweapon->Explode(%d), for eweapon index %u\n", mode, ri->ewpn);
38941 if ( (unsigned) mode > 2 )
38942 {
38943 Z_scripterrlog("Invalid mode (%d) passed to eweapon->Explode(int32_t mode)\n",mode);
38944 }
38945 else
38946 {
38947 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->Explode()") == SH::_NoError)
38948 {
38949 Ewpns.spr(EwpnH::getEWeaponIndex(ri->lwpn))->explode(mode);
38950 }
38951 }
38952 break;
38953 }
38954
38955 case BOTTLENAMEGET:
38956 {
38957 int32_t arrayptr = get_register(sarg1) / 10000;
38958 int32_t id = ri->bottletyperef-1;
38959 if(unsigned(id) > 63)
38960 {
38961 Z_scripterrlog("Invalid bottledata ID (%d) passed to bottledata->GetName().\n", id);
38962 break;
38963 }
38964
38965 if(ArrayH::setArray(arrayptr, QMisc.bottle_types[id].name) == SH::_Overflow)
38966 Z_scripterrlog("Array supplied to 'bottledata->GetName()' not large enough\n");
38967 break;
38968 }
38969 case BOTTLENAMESET:
38970 {
38971 int32_t arrayptr = get_register(sarg1) / 10000;
38972 int32_t id = ri->bottletyperef-1;
38973 if(unsigned(id) > 63)
38974 {
38975 Z_scripterrlog("Invalid bottledata ID (%d) passed to bottledata->SetName().\n", id+1);
38976 break;
38977 }
38978 string name;
38979 ArrayH::getString(arrayptr, name, 31);
38980 strcpy(QMisc.bottle_types[id].name, name.c_str());
38981 break;
38982 }
38983 case BSHOPNAMEGET:
38984 {
38985 int32_t arrayptr = get_register(sarg1) / 10000;
38986 int32_t id = ri->bottleshopref-1;
38987 if(unsigned(id) > 255)
38988 {
38989 Z_scripterrlog("Invalid bottleshopdata ID (%d) passed to bottleshopdata->GetName().\n", id+1);
38990 break;
38991 }
38992
38993 if(ArrayH::setArray(arrayptr, QMisc.bottle_shop_types[id].name) == SH::_Overflow)
38994 Z_scripterrlog("Array supplied to 'bottleshopdata->GetName()' not large enough\n");
38995 break;
38996 }
38997 case BSHOPNAMESET:
38998 {
38999 int32_t arrayptr = get_register(sarg1) / 10000;
39000 int32_t id = ri->bottleshopref;
39001 if(unsigned(id) > 255)
39002 {
39003 Z_scripterrlog("Invalid bottleshopdata ID (%d) passed to bottleshopdata->SetName().\n", id);
39004 break;
39005 }
39006 string name;
39007 ArrayH::getString(arrayptr, name, 31);
39008 strcpy(QMisc.bottle_shop_types[id].name, name.c_str());
39009 break;
39010 }
39011
39012 case RUNITEMSCRIPT:
39013 {
39014 15 int32_t itemid = ri->idata;
39015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(unsigned(itemid) > MAXITEMS) break;
39016 15 int32_t mode = get_register(sarg1) / 10000;
39017 // zprint("Trying to run the script on item: %d\n",itemid);
39018 // zprint("The script ID is: %d\n",itemsbuf[itemid].script);
39019 // zprint("Runitemscript mode is: %d\n", mode);
39020 15 auto& data = get_script_engine_data(ScriptType::Item, itemid);
39021
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 switch(mode)
39022 {
39023 case 0:
39024 {
39025 data.doscript = 4;
39026 break;
39027 }
39028 case 1:
39029 {
39030 if ( itemsbuf[itemid].script != 0 ) //&& !data.doscript )
39031 {
39032 if ( !data.doscript )
39033 {
39034 data.ref.Clear();
39035 data.doscript = 1;
39036 //ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[itemid].script, itemid);
39037 }
39038 else
39039 {
39040 //Emily, clear the stack here, clear refinfo, and set up to run again on the next frame from the beginning.
39041 }
39042 }
39043 break;
39044 }
39045 15 case 2:
39046 default:
39047 {
39048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if ( itemsbuf[itemid].script != 0 ) //&& !data.doscript )
39049 {
39050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if (data.doscript != 2 )data.doscript = 2;
39051 15 }
39052 15 break;
39053 }
39054 /*
39055 case 0:
39056 {
39057 data.doscript = 0;
39058 break;
39059 }
39060 default:
39061 {
39062
39063 if ( itemsbuf[itemid].script != 0 ) //&& !data.doscript )
39064 {
39065 //itemScriptData[itemid].Clear();
39066 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0;
39067 //ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[itemid].script, itemid & 0xFFF);
39068 data.doscript = 2;
39069 }
39070 break;
39071 }
39072 */
39073 }
39074 15 break;
39075 }
39076
39077 //case NPCData
39078
39079 case GETNPCDATATILE: FFScript::getNPCData_tile(); break;
39080 case GETNPCDATAEHEIGHT: FFScript::getNPCData_e_height(); break;
39081 case GETNPCDATAFLAGS: FFScript::getNPCData_flags(); break;
39082 case GETNPCDATAFLAGS2: FFScript::getNPCData_flags2(); break;
39083 case GETNPCDATAWIDTH: FFScript::getNPCData_flags2(); break;
39084 case GETNPCDATAHEIGHT: FFScript::getNPCData_flags2(); break;
39085 case GETNPCDATASTILE: FFScript::getNPCData_s_tile(); break;
39086 case GETNPCDATASWIDTH: FFScript::getNPCData_s_width(); break;
39087 case GETNPCDATASHEIGHT: FFScript::getNPCData_s_height(); break;
39088 case GETNPCDATAETILE: FFScript::getNPCData_e_tile(); break;
39089 case GETNPCDATAEWIDTH: FFScript::getNPCData_e_width(); break;
39090 case GETNPCDATAHP: FFScript::getNPCData_hp(); break;
39091 case GETNPCDATAFAMILY: FFScript::getNPCData_family(); break;
39092 case GETNPCDATACSET: FFScript::getNPCData_cset(); break;
39093 case GETNPCDATAANIM: FFScript::getNPCData_anim(); break;
39094 case GETNPCDATAEANIM: FFScript::getNPCData_e_anim(); break;
39095 case GETNPCDATAFRAMERATE: FFScript::getNPCData_frate(); break;
39096 case GETNPCDATAEFRAMERATE: FFScript::getNPCData_e_frate(); break;
39097 case GETNPCDATATOUCHDMG: FFScript::getNPCData_dp(); break;
39098 case GETNPCDATAWPNDAMAGE: FFScript::getNPCData_wdp(); break;
39099 case GETNPCDATAWEAPON: FFScript::getNPCData_wdp(); break;
39100 case GETNPCDATARANDOM: FFScript::getNPCData_rate(); break;
39101 case GETNPCDATAHALT: FFScript::getNPCData_hrate(); break;
39102 case GETNPCDATASTEP: FFScript::getNPCData_step(); break;
39103 case GETNPCDATAHOMING: FFScript::getNPCData_homing(); break;
39104 case GETNPCDATAHUNGER: FFScript::getNPCData_grumble(); break;
39105 case GETNPCDATADROPSET: FFScript::getNPCData_item_set(); break;
39106 case GETNPCDATABGSFX: FFScript::getNPCData_bgsfx(); break;
39107 case GETNPCDATADEATHSFX: FFScript::getNPCData_deadsfx(); break;
39108 case GETNPCDATAXOFS: FFScript::getNPCData_xofs(); break;
39109 case GETNPCDATAYOFS: FFScript::getNPCData_yofs(); break;
39110 case GETNPCDATAZOFS: FFScript::getNPCData_zofs(); break;
39111 case GETNPCDATAHXOFS: FFScript::getNPCData_hxofs(); break;
39112 case GETNPCDATAHYOFS: FFScript::getNPCData_hyofs(); break;
39113 case GETNPCDATAHITWIDTH: FFScript::getNPCData_hxsz(); break;
39114 case GETNPCDATAHITHEIGHT: FFScript::getNPCData_hysz(); break;
39115 case GETNPCDATAHITZ: FFScript::getNPCData_hzsz(); break;
39116 case GETNPCDATATILEWIDTH: FFScript::getNPCData_txsz(); break;
39117 case GETNPCDATATILEHEIGHT: FFScript::getNPCData_tysz(); break;
39118 case GETNPCDATAWPNSPRITE: FFScript::getNPCData_wpnsprite(); break;
39119 //case GETNPCDATASCRIPTDEF: FFScript::getNPCData_scriptdefence(); break; //2.future cross-compat.
39120 case GETNPCDATADEFENSE: FFScript::getNPCData_defense(); break;
39121 case GETNPCDATASIZEFLAG: FFScript::getNPCData_SIZEflags(); break;
39122 case GETNPCDATAATTRIBUTE: FFScript::getNPCData_misc(); break;
39123 case GETNPCDATAHITSFX: FFScript::getNPCData_hitsfx(); break;
39124
39125 case SETNPCDATAFLAGS: FFScript::setNPCData_flags(); break;
39126 case SETNPCDATAFLAGS2: FFScript::setNPCData_flags2(); break;
39127 case SETNPCDATAWIDTH: FFScript::setNPCData_width(); break;
39128 case SETNPCDATAHEIGHT: FFScript::setNPCData_height(); break;
39129 case SETNPCDATASTILE: FFScript::setNPCData_s_tile(); break;
39130 case SETNPCDATASWIDTH: FFScript::setNPCData_s_width(); break;
39131 case SETNPCDATASHEIGHT: FFScript::setNPCData_s_height(); break;
39132 case SETNPCDATAETILE: FFScript::setNPCData_e_tile(); break;
39133 case SETNPCDATAEWIDTH: FFScript::setNPCData_e_width(); break;
39134 case SETNPCDATAHP: FFScript::setNPCData_hp(); break;
39135 case SETNPCDATAFAMILY: FFScript::setNPCData_family(); break;
39136 case SETNPCDATACSET: FFScript::setNPCData_cset(); break;
39137 case SETNPCDATAANIM: FFScript::setNPCData_anim(); break;
39138 case SETNPCDATAEANIM: FFScript::setNPCData_e_anim(); break;
39139 case SETNPCDATAFRAMERATE: FFScript::setNPCData_frate(); break;
39140 case SETNPCDATAEFRAMERATE: FFScript::setNPCData_e_frate(); break;
39141 case SETNPCDATATOUCHDMG: FFScript::setNPCData_dp(); break;
39142 case SETNPCDATAWPNDAMAGE: FFScript::setNPCData_wdp(); break;
39143 case SETNPCDATAWEAPON: FFScript::setNPCData_weapon(); break;
39144 case SETNPCDATARANDOM: FFScript::setNPCData_rate(); break;
39145 case SETNPCDATAHALT: FFScript::setNPCData_hrate(); break;
39146 case SETNPCDATASTEP: FFScript::setNPCData_step(); break;
39147 case SETNPCDATAHOMING: FFScript::setNPCData_homing(); break;
39148 case SETNPCDATAHUNGER: FFScript::setNPCData_grumble(); break;
39149 case SETNPCDATADROPSET: FFScript::setNPCData_item_set(); break;
39150 case SETNPCDATABGSFX: FFScript::setNPCData_bgsfx(); break;
39151 case SETNPCDATADEATHSFX: FFScript::setNPCData_hitsfx(); break;
39152 case SETNPCDATAXOFS: FFScript::setNPCData_xofs(); break;
39153 case SETNPCDATAYOFS: FFScript::setNPCData_yofs(); break;
39154 case SETNPCDATAZOFS: FFScript::setNPCData_zofs(); break;
39155 case SETNPCDATAHXOFS: FFScript::setNPCData_hxofs(); break;
39156 case SETNPCDATAHYOFS: FFScript::setNPCData_hyofs(); break;
39157 case SETNPCDATAHITWIDTH: FFScript::setNPCData_hxsz(); break;
39158 case SETNPCDATAHITHEIGHT: FFScript::setNPCData_hysz(); break;
39159 case SETNPCDATAHITZ: FFScript::setNPCData_hzsz(); break;
39160 case SETNPCDATATILEWIDTH: FFScript::setNPCData_txsz(); break;
39161 case SETNPCDATATILEHEIGHT: FFScript::setNPCData_tysz(); break;
39162 case SETNPCDATAWPNSPRITE: FFScript::setNPCData_wpnsprite(); break;
39163 case SETNPCDATAHITSFX: FFScript::setNPCData_hitsfx(); break;
39164 case SETNPCDATATILE: FFScript::setNPCData_tile(); break;
39165 case SETNPCDATAEHEIGHT: FFScript::setNPCData_e_height(); break;
39166
39167
39168
39169
39170
39171
39172 //case SETNPCDATASCRIPTDEF : FFScript::setNPCData_scriptdefence(); break;
39173 case SETNPCDATADEFENSE : FFScript::setNPCData_defense(ri->d[rEXP1]); break;
39174 case SETNPCDATASIZEFLAG : FFScript::setNPCData_SIZEflags(ri->d[rEXP1]); break;
39175 case SETNPCDATAATTRIBUTE : FFScript::setNPCData_misc(ri->d[rEXP1]); break;
39176
39177
39178 //ComboData
39179
39180 case GCDBLOCKENEM: FFScript::getComboData_block_enemies(); break;
39181 case GCDBLOCKHOLE: FFScript::getComboData_block_hole(); break;
39182 case GCDBLOCKTRIG: FFScript::getComboData_block_trigger(); break;
39183 case GCDCONVEYSPDX: FFScript::getComboData_conveyor_x_speed(); break;
39184 case GCDCONVEYSPDY: FFScript::getComboData_conveyor_y_speed(); break;
39185 case GCDCREATEENEM: FFScript::getComboData_create_enemy(); break;
39186 case GCDCREATEENEMWH: FFScript::getComboData_create_enemy_when(); break;
39187 case GCDCREATEENEMCH: FFScript::getComboData_create_enemy_change(); break;
39188 case GCDDIRCHTYPE: FFScript::getComboData_directional_change_type(); break;
39189 case GCDDISTCHTILES: FFScript::getComboData_distance_change_tiles(); break;
39190 case GCDDIVEITEM: FFScript::getComboData_dive_item(); break;
39191 case GCDDOCK: FFScript::getComboData_dock(); break;
39192 case GCDFAIRY: FFScript::getComboData_fairy(); break;
39193 case GCDFFCOMBOATTRIB: FFScript::getComboData_ff_combo_attr_change(); break;
39194 case GCDFOOTDECOTILE: FFScript::getComboData_foot_decorations_tile(); break;
39195 case GCDFOOTDECOTYPE: FFScript::getComboData_foot_decorations_type(); break;
39196 case GCDHOOKSHOTGRAB: FFScript::getComboData_hookshot_grab_point(); break;
39197 case GCDLADDERPASS: FFScript::getComboData_ladder_pass(); break;
39198 case GCDLOCKBLOCKTYPE: FFScript::getComboData_lock_block_type(); break;
39199 case GCDLOCKBLOCKCHANGE: FFScript::getComboData_lock_block_change(); break;
39200 case GCDMAGICMIRRORTYPE: FFScript::getComboData_magic_mirror_type(); break;
39201 case GCDMODIFYHPAMOUNT: FFScript::getComboData_modify_hp_amount(); break;
39202 case GCDMODIFYHPDELAY: FFScript::getComboData_modify_hp_delay(); break;
39203 case GCDMODIFYHPTYPE: FFScript::getComboData_modify_hp_type(); break;
39204 case GCDMODIFYMPAMOUNT: FFScript::getComboData_modify_mp_amount(); break;
39205 case GCDMODIFYMPDELAY: FFScript::getComboData_modify_mp_delay(); break;
39206 case GCDMODIFYMPTYPE: FFScript::getComboData_modify_mp_type(); break;
39207 case GCDNOPUSHBLOCKS: FFScript::getComboData_no_push_blocks(); break;
39208 case GCDOVERHEAD: FFScript::getComboData_overhead(); break;
39209 case GCDPLACEENEMY: FFScript::getComboData_place_enemy(); break;
39210 case GCDPUSHDIR: FFScript::getComboData_push_direction(); break;
39211 case GCDPUSHWEIGHT: FFScript::getComboData_push_weight(); break;
39212 case GCDPUSHWAIT: FFScript::getComboData_push_wait(); break;
39213 case GCDPUSHED: FFScript::getComboData_pushed(); break;
39214 case GCDRAFT: FFScript::getComboData_raft(); break;
39215 case GCDRESETROOM: FFScript::getComboData_reset_room(); break;
39216 case GCDSAVEPOINT: FFScript::getComboData_save_point_type(); break;
39217 case GCDSCREENFREEZE: FFScript::getComboData_screen_freeze_type(); break;
39218 case GCDSECRETCOMBO: FFScript::getComboData_secret_combo(); break;
39219 case GCDSINGULAR: FFScript::getComboData_singular(); break;
39220 case GCDSLOWMOVE: FFScript::getComboData_slow_movement(); break;
39221 case GCDSTATUE: FFScript::getComboData_statue_type(); break;
39222 case GCDSTEPTYPE: FFScript::getComboData_step_type(); break;
39223 case GCDSTEPCHANGETO: FFScript::getComboData_step_change_to(); break;
39224 case GCDSTRIKEREMNANTS: FFScript::getComboData_strike_remnants(); break;
39225 case GCDSTRIKEREMNANTSTYPE: FFScript::getComboData_strike_remnants_type(); break;
39226 case GCDSTRIKECHANGE: FFScript::getComboData_strike_change(); break;
39227 case GCDSTRIKECHANGEITEM: FFScript::getComboData_strike_item(); break;
39228 case GCDTOUCHITEM: FFScript::getComboData_touch_item(); break;
39229 case GCDTOUCHSTAIRS: FFScript::getComboData_touch_stairs(); break;
39230 case GCDTRIGGERTYPE: FFScript::getComboData_trigger_type(); break;
39231 case GCDTRIGGERSENS: FFScript::getComboData_trigger_sensitive(); break;
39232 case GCDWARPTYPE: FFScript::getComboData_warp_type(); break;
39233 case GCDWARPSENS: FFScript::getComboData_warp_sensitive(); break;
39234 case GCDWARPDIRECT: FFScript::getComboData_warp_direct(); break;
39235 case GCDWARPLOCATION: FFScript::getComboData_warp_location(); break;
39236 case GCDWATER: FFScript::getComboData_water(); break;
39237 case GCDWHISTLE: FFScript::getComboData_whistle(); break;
39238 case GCDWINGAME: FFScript::getComboData_win_game(); break;
39239 case GCDBLOCKWEAPLVL: FFScript::getComboData_block_weapon_lvl(); break;
39240 case GCDTILE: FFScript::getComboData_tile(); break;
39241 case GCDFLIP: FFScript::getComboData_flip(); break;
39242 case GCDWALK: FFScript::getComboData_walk(); break;
39243 case GCDTYPE: FFScript::getComboData_type(); break;
39244 case GCDCSETS: FFScript::getComboData_csets(); break;
39245 case GCDFOO: break;
39246 case GCDFRAMES: FFScript::getComboData_frames(); break;
39247 case GCDSPEED: FFScript::getComboData_speed(); break;
39248 case GCDNEXTCOMBO: FFScript::getComboData_nextcombo(); break;
39249 case GCDNEXTCSET: FFScript::getComboData_nextcset(); break;
39250 case GCDFLAG: FFScript::getComboData_flag(); break;
39251 case GCDSKIPANIM: FFScript::getComboData_skipanim(); break;
39252 case GCDNEXTTIMER: FFScript::getComboData_nexttimer(); break;
39253 case GCDSKIPANIMY: FFScript::getComboData_skipanimy(); break;
39254 case GCDANIMFLAGS: FFScript::getComboData_animflags(); break;
39255 case GCDBLOCKWEAPON: FFScript::getComboData_block_weapon(); break;
39256 case GCDEXPANSION: FFScript::getComboData_expansion(); break;
39257 case GCDSTRIKEWEAPONS: FFScript::getComboData_strike_weapons(); break;
39258 case SCDBLOCKENEM: FFScript::setComboData_block_enemies(); break;
39259 case SCDBLOCKHOLE: FFScript::setComboData_block_hole(); break;
39260 case SCDBLOCKTRIG: FFScript::setComboData_block_trigger(); break;
39261 case SCDCONVEYSPDX: FFScript::setComboData_conveyor_x_speed(); break;
39262 case SCDCONVEYSPDY: FFScript::setComboData_conveyor_y_speed(); break;
39263 case SCDCREATEENEM: FFScript::setComboData_create_enemy(); break;
39264 case SCDCREATEENEMWH: FFScript::setComboData_create_enemy_when(); break;
39265 case SCDCREATEENEMCH: FFScript::setComboData_create_enemy_change(); break;
39266 case SCDDIRCHTYPE: FFScript::setComboData_directional_change_type(); break;
39267 case SCDDISTCHTILES: FFScript::setComboData_distance_change_tiles(); break;
39268 case SCDDIVEITEM: FFScript::setComboData_dive_item(); break;
39269 case SCDDOCK: FFScript::setComboData_dock(); break;
39270 case SCDFAIRY: FFScript::setComboData_fairy(); break;
39271 case SCDFFCOMBOATTRIB: FFScript::setComboData_ff_combo_attr_change(); break;
39272 case SCDFOOTDECOTILE: FFScript::setComboData_foot_decorations_tile(); break;
39273 case SCDFOOTDECOTYPE: FFScript::setComboData_foot_decorations_type(); break;
39274 case SCDHOOKSHOTGRAB: FFScript::setComboData_hookshot_grab_point(); break;
39275 case SCDLADDERPASS: FFScript::setComboData_ladder_pass(); break;
39276 case SCDLOCKBLOCKTYPE: FFScript::setComboData_lock_block_type(); break;
39277 case SCDLOCKBLOCKCHANGE: FFScript::setComboData_lock_block_change(); break;
39278 case SCDMAGICMIRRORTYPE: FFScript::setComboData_magic_mirror_type(); break;
39279 case SCDMODIFYHPAMOUNT: FFScript::setComboData_modify_hp_amount(); break;
39280 case SCDMODIFYHPDELAY: FFScript::setComboData_modify_hp_delay(); break;
39281 case SCDMODIFYHPTYPE: FFScript::setComboData_modify_hp_type(); break;
39282 case SCDMODIFYMPAMOUNT: FFScript::setComboData_modify_mp_amount(); break;
39283 case SCDMODIFYMPDELAY: FFScript::setComboData_modify_mp_delay(); break;
39284 case SCDMODIFYMPTYPE: FFScript::setComboData_modify_mp_type(); break;
39285 case SCDNOPUSHBLOCKS: FFScript::setComboData_no_push_blocks(); break;
39286 case SCDOVERHEAD: FFScript::setComboData_overhead(); break;
39287 case SCDPLACEENEMY: FFScript::setComboData_place_enemy(); break;
39288 case SCDPUSHDIR: FFScript::setComboData_push_direction(); break;
39289 case SCDPUSHWEIGHT: FFScript::setComboData_push_weight(); break;
39290 case SCDPUSHWAIT: FFScript::setComboData_push_wait(); break;
39291 case SCDPUSHED: FFScript::setComboData_pushed(); break;
39292 case SCDRAFT: FFScript::setComboData_raft(); break;
39293 case SCDRESETROOM: FFScript::setComboData_reset_room(); break;
39294 case SCDSAVEPOINT: FFScript::setComboData_save_point_type(); break;
39295 case SCDSCREENFREEZE: FFScript::setComboData_screen_freeze_type(); break;
39296 case SCDSECRETCOMBO: FFScript::setComboData_secret_combo(); break;
39297 case SCDSINGULAR: FFScript::setComboData_singular(); break;
39298 case SCDSLOWMOVE: FFScript::setComboData_slow_movement(); break;
39299 case SCDSTATUE: FFScript::setComboData_statue_type(); break;
39300 case SCDSTEPTYPE: FFScript::setComboData_step_type(); break;
39301 case SCDSTEPCHANGETO: FFScript::setComboData_step_change_to(); break;
39302 case SCDSTRIKEREMNANTS: FFScript::setComboData_strike_remnants(); break;
39303 case SCDSTRIKEREMNANTSTYPE: FFScript::setComboData_strike_remnants_type(); break;
39304 case SCDSTRIKECHANGE: FFScript::setComboData_strike_change(); break;
39305 case SCDSTRIKECHANGEITEM: FFScript::setComboData_strike_item(); break;
39306 case SCDTOUCHITEM: FFScript::setComboData_touch_item(); break;
39307 case SCDTOUCHSTAIRS: FFScript::setComboData_touch_stairs(); break;
39308 case SCDTRIGGERTYPE: FFScript::setComboData_trigger_type(); break;
39309 case SCDTRIGGERSENS: FFScript::setComboData_trigger_sensitive(); break;
39310 case SCDWARPTYPE: FFScript::setComboData_warp_type(); break;
39311 case SCDWARPSENS: FFScript::setComboData_warp_sensitive(); break;
39312 case SCDWARPDIRECT: FFScript::setComboData_warp_direct(); break;
39313 case SCDWARPLOCATION: FFScript::setComboData_warp_location(); break;
39314 case SCDWATER: FFScript::setComboData_water(); break;
39315 case SCDWHISTLE: FFScript::setComboData_whistle(); break;
39316 case SCDWINGAME: FFScript::setComboData_win_game(); break;
39317 case SCDBLOCKWEAPLVL: FFScript::setComboData_block_weapon_lvl(); break;
39318 case SCDTILE: FFScript::setComboData_tile(); break;
39319 case SCDFLIP: FFScript::setComboData_flip(); break;
39320 case SCDWALK: FFScript::setComboData_walk(); break;
39321 case SCDTYPE: FFScript::setComboData_type(); break;
39322 case SCDCSETS: FFScript::setComboData_csets(); break;
39323 case SCDFOO: break;
39324 case SCDFRAMES: FFScript::setComboData_frames(); break;
39325 case SCDSPEED: FFScript::setComboData_speed(); break;
39326 case SCDNEXTCOMBO: FFScript::setComboData_nextcombo(); break;
39327 case SCDNEXTCSET: FFScript::setComboData_nextcset(); break;
39328 case SCDFLAG: FFScript::setComboData_flag(); break;
39329 case SCDSKIPANIM: FFScript::setComboData_skipanim(); break;
39330 case SCDNEXTTIMER: FFScript::setComboData_nexttimer(); break;
39331 case SCDSKIPANIMY: FFScript::setComboData_skipanimy(); break;
39332 case SCDANIMFLAGS: FFScript::setComboData_animflags(); break;
39333 case SCDBLOCKWEAPON: FFScript::setComboData_block_weapon(ri->d[rEXP1]); break;
39334 case SCDEXPANSION: FFScript::setComboData_expansion(ri->d[rEXP1]); break;
39335 case SCDSTRIKEWEAPONS: FFScript::setComboData_strike_weapons(ri->d[rEXP1]); break;
39336
39337 //SpriteData
39338
39339 //case GETSPRITEDATASTRING:
39340 case GETSPRITEDATATILE: FFScript::getSpriteDataTile(); break;
39341 case GETSPRITEDATAMISC: FFScript::getSpriteDataCSets(); break;
39342 case GETSPRITEDATACGETS: FFScript::getSpriteDataCSets(); break;
39343 case GETSPRITEDATAFRAMES: FFScript::getSpriteDataFrames(); break;
39344 case GETSPRITEDATASPEED: FFScript::getSpriteDataSpeed(); break;
39345 case GETSPRITEDATATYPE: FFScript::getSpriteDataType(); break;
39346
39347 //case SETSPRITEDATASTRING:
39348 case SETSPRITEDATATILE: FFScript::setSpriteDataTile(); break;
39349 case SETSPRITEDATAMISC: FFScript::setSpriteDataMisc(); break;
39350 case SETSPRITEDATACSETS: FFScript::setSpriteDataCSets(); break;
39351 case SETSPRITEDATAFRAMES: FFScript::setSpriteDataFrames(); break;
39352 case SETSPRITEDATASPEED: FFScript::setSpriteDataSpeed(); break;
39353 case SETSPRITEDATATYPE: FFScript::setSpriteDataType(); break;
39354
39355 //Game over Screen
39356 case SETCONTINUESCREEN: FFScript::FFChangeSubscreenText(); break;
39357 case SETCONTINUESTRING: FFScript::FFSetSaveScreenSetting(); break;
39358
39359 //new npc functions for npc scripts
39360
39361 case NPCDEAD:
39362 FFCore.do_isdeadnpc();
39363 break;
39364
39365 case NPCCANSLIDE:
39366 FFCore.do_canslidenpc();
39367 break;
39368
39369 case NPCSLIDE:
39370 FFCore.do_slidenpc();
39371 break;
39372
39373 case NPCKICKBUCKET:
39374 {
39375 FFScript::deallocateAllScriptOwned(ScriptType::NPC, ri->guyref);
39376 if(type == ScriptType::NPC && ri->guyref == i)
39377 {
39378 FFCore.do_npc_delete();
39379 return RUNSCRIPT_SELFDELETE;
39380 }
39381 FFCore.do_npc_delete();
39382 break;
39383 }
39384 case LWPNDEL:
39385 {
39386 FFScript::deallocateAllScriptOwned(ScriptType::Lwpn, ri->lwpn);
39387 if(type == ScriptType::Lwpn && ri->lwpn == i)
39388 {
39389 FFCore.do_lweapon_delete();
39390 return RUNSCRIPT_SELFDELETE;
39391 }
39392 FFCore.do_lweapon_delete();
39393 break;
39394 }
39395 case EWPNDEL:
39396 {
39397 FFScript::deallocateAllScriptOwned(ScriptType::Ewpn, ri->ewpn);
39398 if(type == ScriptType::Ewpn && ri->ewpn == i)
39399 {
39400 FFCore.do_eweapon_delete();
39401 return RUNSCRIPT_SELFDELETE;
39402 }
39403 FFCore.do_eweapon_delete();
39404 break;
39405 }
39406 case ITEMDEL:
39407 {
39408 8 FFScript::deallocateAllScriptOwned(ScriptType::ItemSprite, ri->itemref);
39409
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(type == ScriptType::ItemSprite && ri->itemref == i)
39410 {
39411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(FFCore.do_itemsprite_delete())
39412 8 return RUNSCRIPT_SELFDELETE;
39413 }
39414 else FFCore.do_itemsprite_delete();
39415 break;
39416 }
39417
39418 case NPCSTOPBGSFX:
39419 FFCore.do_npc_stopbgsfx();
39420 break;
39421
39422 case NPCATTACK:
39423 FFCore.do_npcattack();
39424 break;
39425
39426 case NPCNEWDIR:
39427 FFCore.do_npc_newdir();
39428 break;
39429
39430 case NPCCONSTWALK:
39431 FFCore.do_npc_constwalk();
39432 break;
39433
39434
39435
39436 case NPCVARWALK:
39437 FFCore.do_npc_varwalk();
39438 break;
39439
39440 case NPCVARWALK8:
39441 FFCore.do_npc_varwalk8();
39442 break;
39443
39444 case NPCCONSTWALK8:
39445 FFCore.do_npc_constwalk8();
39446 break;
39447
39448 case NPCHALTWALK:
39449 FFCore.do_npc_haltwalk();
39450 break;
39451
39452 case NPCHALTWALK8:
39453 FFCore.do_npc_haltwalk8();
39454 break;
39455
39456 case NPCFLOATWALK:
39457 FFCore.do_npc_floatwalk();
39458 break;
39459
39460 case NPCFIREBREATH:
39461 FFCore.do_npc_breathefire();
39462 break;
39463
39464 case NPCNEWDIR8:
39465 FFCore.do_npc_newdir8();
39466 break;
39467
39468 case NPCLINKINRANGE:
39469 FFCore.do_npc_hero_in_range(false);
39470 break;
39471
39472 case NPCCANMOVE:
39473 FFCore.do_npc_canmove(false);
39474 break;
39475
39476 case NPCHITWITH:
39477 FFCore.do_npc_simulate_hit(false);
39478 break;
39479
39480 case NPCKNOCKBACK:
39481 FFCore.do_npc_knockback(false);
39482 break;
39483
39484 case NPCGETINITDLABEL:
39485 FFCore.get_npcdata_initd_label(false);
39486 break;
39487
39488 case NPCADD:
39489 FFCore.do_npc_add(false);
39490 break;
39491
39492 case NPCMOVEPAUSED:
39493 {
39494 ri->d[rEXP1] = 0;
39495 if(GuyH::loadNPC(ri->guyref, "npc->MovePaused()") == SH::_NoError)
39496 {
39497 ri->d[rEXP1] = GuyH::getNPC()->is_move_paused() ? 10000 : 0;
39498 }
39499 break;
39500 }
39501 case NPCMOVE:
39502 {
39503 int32_t dir = ri->d[rINDEX] / 10000;
39504 zfix px = zslongToFix(ri->d[rEXP2]);
39505 int32_t special = ri->d[rEXP1] / 10000;
39506 ri->d[rEXP1] = 0;
39507 if(GuyH::loadNPC(ri->guyref, "npc->Move()") == SH::_NoError)
39508 {
39509 ri->d[rEXP1] = GuyH::getNPC()->moveDir(dir, px, special) ? 10000 : 0;
39510 }
39511 break;
39512 }
39513 case NPCMOVEANGLE:
39514 {
39515 zfix degrees = zslongToFix(ri->d[rINDEX]);
39516 zfix px = zslongToFix(ri->d[rEXP2]);
39517 int32_t special = ri->d[rEXP1] / 10000;
39518 ri->d[rEXP1] = 0;
39519 if(GuyH::loadNPC(ri->guyref, "npc->MoveAtAngle()") == SH::_NoError)
39520 {
39521 ri->d[rEXP1] = GuyH::getNPC()->moveAtAngle(degrees, px, special) ? 10000 : 0;
39522 }
39523 break;
39524 }
39525 case NPCMOVEXY:
39526 {
39527 zfix dx = zslongToFix(ri->d[rINDEX]);
39528 zfix dy = zslongToFix(ri->d[rEXP2]);
39529 int32_t special = ri->d[rEXP1] / 10000;
39530 ri->d[rEXP1] = 0;
39531 if(GuyH::loadNPC(ri->guyref, "npc->MoveXY()") == SH::_NoError)
39532 {
39533 ri->d[rEXP1] = GuyH::getNPC()->movexy(dx, dy, special) ? 10000 : 00;
39534 }
39535 break;
39536 }
39537 case NPCCANMOVEDIR:
39538 {
39539 int32_t dir = ri->d[rINDEX] / 10000;
39540 zfix px = zslongToFix(ri->d[rEXP2]);
39541 int32_t special = ri->d[rEXP1] / 10000;
39542 ri->d[rEXP1] = 0;
39543 if(GuyH::loadNPC(ri->guyref, "npc->CanMove()") == SH::_NoError)
39544 {
39545 ri->d[rEXP1] = GuyH::getNPC()->can_moveDir(dir, px, special) ? 10000 : 0;
39546 }
39547 break;
39548 }
39549 case NPCCANMOVEANGLE:
39550 {
39551 zfix degrees = zslongToFix(ri->d[rINDEX]);
39552 zfix px = zslongToFix(ri->d[rEXP2]);
39553 int32_t special = ri->d[rEXP1] / 10000;
39554 ri->d[rEXP1] = 0;
39555 if(GuyH::loadNPC(ri->guyref, "npc->CanMoveAtAngle()") == SH::_NoError)
39556 {
39557 ri->d[rEXP1] = GuyH::getNPC()->can_moveAtAngle(degrees, px, special) ? 10000 : 0;
39558 }
39559 break;
39560 }
39561 case NPCCANMOVEXY:
39562 {
39563 zfix dx = zslongToFix(ri->d[rINDEX]);
39564 zfix dy = zslongToFix(ri->d[rEXP2]);
39565 int32_t special = ri->d[rEXP1] / 10000;
39566 ri->d[rEXP1] = 0;
39567 if(GuyH::loadNPC(ri->guyref, "npc->CanMoveXY()") == SH::_NoError)
39568 {
39569 ri->d[rEXP1] = GuyH::getNPC()->can_movexy(dx, dy, special) ? 10000 : 0;
39570 }
39571 break;
39572 }
39573 case NPCCANPLACE:
39574 {
39575 ri->guyref = SH::read_stack(ri->sp + 6);
39576 ri->d[rEXP1] = 0;
39577 if(GuyH::loadNPC(ri->guyref, "npc->CanPlace()") == SH::_NoError)
39578 {
39579 zfix nx = zslongToFix(SH::read_stack(ri->sp + 5));
39580 zfix ny = zslongToFix(SH::read_stack(ri->sp + 4));
39581 int special = SH::read_stack(ri->sp + 3) / 10000;
39582 bool kb = SH::read_stack(ri->sp + 2)!=0;
39583 int nw = SH::read_stack(ri->sp + 1) / 10000;
39584 int nh = SH::read_stack(ri->sp + 0) / 10000;
39585 ri->d[rEXP1] = GuyH::getNPC()->scr_canplace(nx, ny, special, kb, nw, nh) ? 10000 : 0;
39586 }
39587 break;
39588 }
39589
39590 case PLAYENHMUSICEX:
39591 // DEPRECATED
39592 do_enh_music(false);
39593 break;
39594
39595 case GETENHMUSICPOS:
39596 FFCore.do_get_music_position();
39597 break;
39598
39599 case SETENHMUSICPOS:
39600 FFCore.do_set_music_position(false);
39601 break;
39602
39603 case SETENHMUSICSPEED:
39604 FFCore.do_set_music_speed(false);
39605 break;
39606
39607 case GETENHMUSICLEN:
39608 FFCore.do_get_music_length();
39609 break;
39610
39611 case SETENHMUSICLOOP:
39612 FFCore.do_set_music_loop();
39613 break;
39614
39615 case ENHCROSSFADE:
39616 do_enh_music_crossfade();
39617 break;
39618
39619 case DIREXISTS:
39620 FFCore.do_checkdir(true);
39621 break;
39622
39623 case FILEEXISTS:
39624 FFCore.do_checkdir(false);
39625 break;
39626
39627 case FILESYSREMOVE:
39628 FFCore.do_fs_remove();
39629 break;
39630
39631 case TOBYTE:
39632 do_tobyte();
39633 break;
39634 case TOWORD:
39635 do_toword();
39636 break;
39637 case TOSHORT: do_toshort(); break;
39638 case TOSIGNEDBYTE: do_tosignedbyte(); break;
39639 case TOINTEGER: do_tointeger(); break;
39640 case CEILING: do_ceiling(); break;
39641 case FLOOR: do_floor(); break;
39642
39643 case FILECLOSE:
39644 {
39645 FFCore.do_fclose();
39646 break;
39647 }
39648 case FILEFREE:
39649 {
39650 1 FFCore.do_deallocate_file();
39651 1 break;
39652 }
39653 case FILEOWN:
39654 {
39655 1 user_file* f = checkFile(ri->fileref, "Free()", false);
39656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(f) f->own(type, i);
39657 1 break;
39658 }
39659 case FILEISALLOCATED:
39660 {
39661 FFCore.do_file_isallocated();
39662 break;
39663 }
39664 case FILEISVALID:
39665 {
39666 FFCore.do_file_isvalid();
39667 break;
39668 }
39669 case FILEALLOCATE:
39670 {
39671 FFCore.do_allocate_file();
39672 break;
39673 }
39674 case FILEFLUSH:
39675 {
39676 1 FFCore.do_fflush();
39677 1 break;
39678 }
39679 case FILEREMOVE:
39680 {
39681 FFCore.do_fremove();
39682 break;
39683 }
39684 case FILEGETCHAR:
39685 {
39686 FFCore.do_file_getchar();
39687 break;
39688 }
39689 case FILEREWIND:
39690 {
39691 FFCore.do_file_rewind();
39692 break;
39693 }
39694 case FILECLEARERR:
39695 {
39696 FFCore.do_file_clearerr();
39697 break;
39698 }
39699
39700 case FILEOPEN:
39701 {
39702 1 FFCore.do_fopen(false, "rb+");
39703 1 break;
39704 }
39705 case FILECREATE:
39706 {
39707 1 FFCore.do_fopen(false, "wb+");
39708 1 break;
39709 }
39710 case FILEOPENMODE:
39711 {
39712 int32_t arrayptr = get_register(sarg2) / 10000;
39713 string mode;
39714 ArrayH::getString(arrayptr, mode, 16);
39715 FFCore.do_fopen(false, mode.c_str());
39716 break;
39717 }
39718 case FILEREADSTR:
39719 {
39720 FFCore.do_file_readstring();
39721 break;
39722 }
39723 case FILEWRITESTR:
39724 {
39725 279 FFCore.do_file_writestring();
39726 279 break;
39727 }
39728 case FILEPUTCHAR:
39729 {
39730 FFCore.do_file_putchar();
39731 break;
39732 }
39733 case FILEUNGETCHAR:
39734 {
39735 FFCore.do_file_ungetchar();
39736 break;
39737 }
39738
39739 case FILEREADCHARS:
39740 {
39741 FFCore.do_file_readchars();
39742 break;
39743 }
39744 case FILEREADBYTES:
39745 {
39746 FFCore.do_file_readbytes();
39747 break;
39748 }
39749 case FILEREADINTS:
39750 {
39751 FFCore.do_file_readints();
39752 break;
39753 }
39754 case FILEWRITECHARS:
39755 {
39756 FFCore.do_file_writechars();
39757 break;
39758 }
39759 case FILEWRITEBYTES:
39760 {
39761 FFCore.do_file_writebytes();
39762 break;
39763 }
39764 case FILEWRITEINTS:
39765 {
39766 FFCore.do_file_writeints();
39767 break;
39768 }
39769 case FILESEEK:
39770 {
39771 FFCore.do_file_seek();
39772 break;
39773 }
39774 case FILEGETERROR:
39775 {
39776 FFCore.do_file_geterr();
39777 break;
39778 }
39779 //Directory
39780 case DIRECTORYGET:
39781 {
39782 FFCore.do_directory_get();
39783 break;
39784 }
39785 case DIRECTORYRELOAD:
39786 {
39787 FFCore.do_directory_reload();
39788 break;
39789 }
39790 case DIRECTORYFREE:
39791 {
39792 FFCore.do_directory_free();
39793 break;
39794 }
39795 case DIRECTORYOWN:
39796 {
39797 if(user_dir* dr = checkDir(ri->directoryref, "Own()"))
39798 {
39799 dr->own(type, i);
39800 }
39801 break;
39802 }
39803 //Stack
39804 case STACKFREE:
39805 {
39806 if(user_stack* st = checkStack(ri->stackref, "Free()", true))
39807 {
39808 st->clear();
39809 }
39810 break;
39811 }
39812 case STACKOWN:
39813 {
39814 if(user_stack* st = checkStack(ri->stackref, "Own()"))
39815 {
39816 st->own(type, i);
39817 }
39818 break;
39819 }
39820 case STACKCLEAR:
39821 {
39822 if(user_stack* st = checkStack(ri->stackref, "Clear()"))
39823 {
39824 st->clearStack();
39825 }
39826 break;
39827 }
39828 case STACKGET:
39829 {
39830 if(user_stack* st = checkStack(ri->stackref, "Get()", true))
39831 {
39832 int32_t indx = get_register(sarg1); //NOT /10000
39833 set_register(sarg1, st->get(indx)); //NOT *10000
39834 }
39835 else set_register(sarg1, 0L);
39836 break;
39837 }
39838 case STACKSET:
39839 {
39840 if(user_stack* st = checkStack(ri->stackref, "Set()", true))
39841 {
39842 int32_t indx = get_register(sarg1); //NOT /10000
39843 int32_t val = get_register(sarg2); //NOT /10000
39844 st->set(indx, val); //NOT *10000
39845 }
39846 break;
39847 }
39848 case STACKPOPBACK:
39849 {
39850 if(user_stack* st = checkStack(ri->stackref, "PopBack()", true))
39851 {
39852 set_register(sarg1, st->pop_back()); //NOT *10000
39853 }
39854 else set_register(sarg1, 0L);
39855 break;
39856 }
39857 case STACKPOPFRONT:
39858 {
39859 if(user_stack* st = checkStack(ri->stackref, "PopFront()", true))
39860 {
39861 set_register(sarg1, st->pop_front()); //NOT *10000
39862 }
39863 else set_register(sarg1, 0L);
39864 break;
39865 }
39866 case STACKPEEKBACK:
39867 {
39868 if(user_stack* st = checkStack(ri->stackref, "PeekBack()", true))
39869 {
39870 set_register(sarg1, st->peek_back()); //NOT *10000
39871 }
39872 else set_register(sarg1, 0L);
39873 break;
39874 }
39875 case STACKPEEKFRONT:
39876 {
39877 if(user_stack* st = checkStack(ri->stackref, "PeekFront()", true))
39878 {
39879 set_register(sarg1, st->peek_front()); //NOT *10000
39880 }
39881 else set_register(sarg1, 0L);
39882 break;
39883 }
39884 case STACKPUSHBACK:
39885 {
39886 if(user_stack* st = checkStack(ri->stackref, "PushBack()", true))
39887 {
39888 int32_t val = get_register(sarg1); //NOT /10000
39889 st->push_back(val);
39890 }
39891 break;
39892 }
39893 case STACKPUSHFRONT:
39894 {
39895 if(user_stack* st = checkStack(ri->stackref, "PushFront()", true))
39896 {
39897 int32_t val = get_register(sarg1); //NOT /10000
39898 st->push_front(val);
39899 }
39900 break;
39901 }
39902
39903 //Module
39904 case MODULEGETIC:
39905 {
39906
39907 int32_t buf_pointer = SH::get_arg(sarg1, false) / 10000;
39908 int32_t element = SH::get_arg(sarg2, false) / 10000;
39909
39910 if ( ((unsigned)element) > 511 )
39911 {
39912 Z_scripterrlog("Illegal itemclass supplied to ZInfo->GetItemClass().\nLegal values are 1 to 511.\n");
39913 }
39914 else
39915 {
39916 char buffer[256] = {0};
39917 strcpy(buffer,ZI.getItemClassName(element));
39918 buffer[255] = '\0';
39919 if(ArrayH::setArray(buf_pointer, buffer) == SH::_Overflow)
39920 {
39921 Z_scripterrlog("Dest string supplied to 'Module->GetItemClass()' is not large enough\n");
39922 }
39923 }
39924
39925 break;
39926 }
39927
39928 //{ Randgen Stuff
39929 case RNGRAND1:
39930 if(user_rng* r = checkRNG(ri->rngref, "Rand()"))
39931 {
39932 ri->d[rEXP1] = r->rand(214748, -214748)*10000L;
39933 }
39934 else ri->d[rEXP1] = -10000L;
39935 break;
39936 case RNGRAND2:
39937
1/2
✓ Branch 0 taken 1338 times.
✗ Branch 1 not taken.
1338 if(user_rng* r = checkRNG(ri->rngref, "Rand(int32_t)"))
39938 {
39939 1338 set_register(sarg1,r->rand(get_register(sarg1)/10000L)*10000L);
39940 1338 }
39941 else set_register(sarg1,-10000L);
39942 1338 break;
39943 case RNGRAND3:
39944
1/2
✓ Branch 0 taken 301905 times.
✗ Branch 1 not taken.
301905 if(user_rng* r = checkRNG(ri->rngref, "Rand(int32_t,int32_t)"))
39945 {
39946 301905 set_register(sarg1,r->rand(get_register(sarg1)/10000L, get_register(sarg2)/10000L)* 10000L);
39947 301905 }
39948 else set_register(sarg1,-10000L);
39949 301905 break;
39950 case RNGLRAND1:
39951 if(user_rng* r = checkRNG(ri->rngref, "LRand()"))
39952 {
39953 ri->d[rEXP1] = r->rand();
39954 }
39955 else ri->d[rEXP1] = -10000L;
39956 break;
39957 case RNGLRAND2:
39958 if(user_rng* r = checkRNG(ri->rngref, "LRand(int32_t)"))
39959 {
39960 ri->d[rEXP1] = r->rand(get_register(sarg1));
39961 }
39962 else ri->d[rEXP1] = -10000L;
39963 break;
39964 case RNGLRAND3:
39965 if(user_rng* r = checkRNG(ri->rngref, "LRand(int32_t,int32_t)"))
39966 {
39967 ri->d[rEXP1] = r->rand(get_register(sarg1), get_register(sarg2));
39968 }
39969 else ri->d[rEXP1] = -10000L;
39970 break;
39971 case RNGSEED:
39972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(user_rng* r = checkRNG(ri->rngref, "SRand(int32_t)"))
39973 {
39974 73 r->srand(get_register(sarg1));
39975 73 }
39976 73 break;
39977 case RNGRSEED:
39978 if(user_rng* r = checkRNG(ri->rngref, "SRand()"))
39979 {
39980 ri->d[rEXP1] = r->srand();
39981 }
39982 else ri->d[rEXP1] = -10000;
39983 break;
39984 case RNGFREE:
39985
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(user_rng* r = checkRNG(ri->rngref, "Free()", true))
39986 {
39987 6 r->clear();
39988 6 }
39989 6 break;
39990 case RNGOWN:
39991
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(user_rng* r = checkRNG(ri->rngref, "Own()", false))
39992 {
39993 8 r->own(type, i);
39994 8 }
39995 8 break;
39996 //}
39997 case LOADGENERICDATA:
39998 68 FFCore.do_loadgenericdata(false); break;
39999 case RUNGENFRZSCR:
40000 {
40001 10 bool r = FFCore.runGenericFrozenEngine(word(ri->genericdataref));
40002 10 set_register(sarg1, r ? 10000L : 0L);
40003 10 break;
40004 }
40005
40006 ///----------------------------------------------------------------------------------------------------//
40007
40008 case SUBDATA_GET_NAME:
40009 {
40010 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "GetName"))
40011 {
40012 auto aptr = get_register(sarg1) / 10000;
40013 if(ArrayH::setArray(aptr, sub->name, true) == SH::_Overflow)
40014 Z_scripterrlog("Array supplied to 'subscreendata->GetName()' not large enough,"
40015 " and couldn't be resized!\n");
40016 }
40017 break;
40018 }
40019 case SUBDATA_SET_NAME:
40020 {
40021 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SetName"))
40022 {
40023 auto aptr = get_register(sarg1) / 10000;
40024 ArrayH::getString(aptr, sub->name);
40025 }
40026 break;
40027 }
40028 case SUBDATA_SWAP_PAGES:
40029 {
40030 ri->subdataref = SH::read_stack(ri->sp+2);
40031 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SwapPages"))
40032 {
40033 int p1 = SH::read_stack(ri->sp+1) / 10000;
40034 int p2 = SH::read_stack(ri->sp+0) / 10000;
40035 if(unsigned(p1) >= sub->pages.size())
40036 Z_scripterrlog("Invalid page index '%d' passed to subscreendata->SwapPages()\n", p1);
40037 else if(unsigned(p2) >= sub->pages.size())
40038 Z_scripterrlog("Invalid page index '%d' passed to subscreendata->SwapPages()\n", p2);
40039 else sub->swap_pages(p1,p2);
40040 }
40041 break;
40042 }
40043 case SUBPAGE_SWAP_WIDG:
40044 {
40045 ri->subpageref = SH::read_stack(ri->sp+2);
40046 if(SubscrPage* pg = checkSubPage(ri->subpageref, "SwapWidgets"))
40047 {
40048 int p1 = SH::read_stack(ri->sp+1) / 10000;
40049 int p2 = SH::read_stack(ri->sp+0) / 10000;
40050 if(unsigned(p1) >= pg->size())
40051 Z_scripterrlog("Invalid page index '%d' passed to subscreenpage->SwapWidgets()\n", p1);
40052 else if(unsigned(p2) >= pg->size())
40053 Z_scripterrlog("Invalid page index '%d' passed to subscreenpage->SwapWidgets()\n", p2);
40054 else pg->swap_widg(p1,p2);
40055 }
40056 break;
40057 }
40058 case SUBPAGE_FIND_WIDGET:
40059 {
40060 ri->d[rEXP1] = 0;
40061 ri->subpageref = SH::read_stack(ri->sp+1);
40062 if(SubscrPage* pg = checkSubPage(ri->subpageref, "FindWidget", sstACTIVE))
40063 {
40064 int cursorpos = SH::read_stack(ri->sp+0) / 10000;
40065 if(auto* widg = pg->get_widg_pos(cursorpos,false))
40066 {
40067 auto q = pg->widget_index(widg);
40068 if(q > -1)
40069 {
40070 auto [sub,ty,pgid,_ind] = from_subref(ri->subpageref);
40071 ri->d[rEXP1] = get_subref(sub,ty,pgid,q);
40072 }
40073 }
40074 }
40075 break;
40076 }
40077 case SUBPAGE_FIND_WIDGET_BY_LABEL:
40078 {
40079 ri->d[rEXP1] = 0;
40080 ri->subpageref = SH::read_stack(ri->sp+1);
40081 if(SubscrPage* pg = checkSubPage(ri->subpageref, "GetWidget"))
40082 {
40083 int aptr = SH::read_stack(ri->sp+0) / 10000;
40084 std::string lbl;
40085 ArrayH::getString(aptr, lbl);
40086 if(lbl.size())
40087 {
40088 auto q = pg->find_label_index(lbl);
40089 if(q > -1)
40090 {
40091 auto [sub,ty,pgid,_ind] = from_subref(ri->subpageref);
40092 ri->d[rEXP1] = get_subref(sub,ty,pgid,q);
40093 }
40094 }
40095 }
40096 break;
40097 }
40098 case SUBPAGE_MOVE_SEL:
40099 {
40100 #define SUBSEL_FLAG_NO_NONEQUIP 0x01
40101 #define SUBSEL_FLAG_NEED_ITEM 0x02
40102 ri->subpageref = SH::read_stack(ri->sp+3);
40103 if(SubscrPage* pg = checkSubPage(ri->subpageref, "SelectorMove"))
40104 {
40105 int flags = SH::read_stack(ri->sp+0) / 10000;
40106 int dir = SH::read_stack(ri->sp+1) / 10000;
40107 int pos = SH::read_stack(ri->sp+2) / 10000;
40108 switch(dir)
40109 {
40110 case up:
40111 dir = SEL_UP;
40112 break;
40113 case down:
40114 dir = SEL_DOWN;
40115 break;
40116 case left:
40117 dir = SEL_LEFT;
40118 break;
40119 case right: default:
40120 dir = SEL_RIGHT;
40121 break;
40122 }
40123
40124 auto newpos = pg->movepos_legacy(dir, (pos<<8)|pg->getIndex(),
40125 255, 255, 255, flags&SUBSEL_FLAG_NO_NONEQUIP,
40126 flags&SUBSEL_FLAG_NEED_ITEM, true) >> 8;
40127 ri->d[rEXP1] = 10000*newpos;
40128 }
40129 break;
40130 }
40131 case SUBPAGE_NEW_WIDG:
40132 {
40133 ri->subpageref = SH::read_stack(ri->sp+1);
40134 if(SubscrPage* pg = checkSubPage(ri->subpageref, "CreateWidget"))
40135 {
40136 if(pg->size() == 0x2000)
40137 break; //Page is full!
40138 int ty = SH::read_stack(ri->sp+0) / 10000;
40139 if(auto* widg = SubscrWidget::newType(ty))
40140 {
40141 widg->posflags = sspUP | sspDOWN | sspSCROLLING;
40142 widg->w = 1;
40143 widg->h = 1;
40144 pg->push_back(widg);
40145 auto [sub,ty,pgid,_ind] = from_subref(ri->subpageref);
40146 ri->d[rEXP1] = get_subref(sub,ty,pgid,pg->size()-1);
40147 }
40148 else Z_scripterrlog("Invalid type %d passed to subscreenpage->CreateWidget()\n",ty);
40149 }
40150 break;
40151 }
40152 case SUBPAGE_DELETE:
40153 {
40154 if(SubscrPage* pg = checkSubPage(ri->subpageref, "Delete"))
40155 {
40156 auto [sub,_ty] = load_subdata(ri->subpageref);
40157 sub->delete_page(pg->getIndex());
40158 }
40159 break;
40160 }
40161 case SUBWIDG_GET_SELTEXT_OVERRIDE:
40162 {
40163 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GetSelTextOverride"))
40164 {
40165 auto aptr = get_register(sarg1) / 10000;
40166 if(ArrayH::setArray(aptr, widg->override_text, true) == SH::_Overflow)
40167 Z_scripterrlog("Array supplied to 'subscreenwidget->GetSelTextOverride()' not large enough,"
40168 " and couldn't be resized!\n");
40169 }
40170 break;
40171 }
40172 case SUBWIDG_SET_SELTEXT_OVERRIDE:
40173 {
40174 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SetSelTextOverride"))
40175 {
40176 auto aptr = get_register(sarg1) / 10000;
40177 ArrayH::getString(aptr, widg->override_text);
40178 }
40179 break;
40180 }
40181 case SUBWIDG_GET_LABEL:
40182 {
40183 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GetLabel"))
40184 {
40185 auto aptr = get_register(sarg1) / 10000;
40186 if(ArrayH::setArray(aptr, widg->label, true) == SH::_Overflow)
40187 Z_scripterrlog("Array supplied to 'subscreenwidget->GetLabel()' not large enough,"
40188 " and couldn't be resized!\n");
40189 }
40190 break;
40191 }
40192 case SUBWIDG_SET_LABEL:
40193 {
40194 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SetLabel"))
40195 {
40196 auto aptr = get_register(sarg1) / 10000;
40197 ArrayH::getString(aptr, widg->label);
40198 }
40199 break;
40200 }
40201 case SUBWIDG_TY_GETTEXT:
40202 {
40203 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GetText"))
40204 {
40205 std::string const* str = nullptr;
40206 byte ty = widg->getType();
40207 switch(ty)
40208 {
40209 case widgTEXT:
40210 str = &((SW_Text*)widg)->text;
40211 break;
40212 case widgTEXTBOX:
40213 str = &((SW_TextBox*)widg)->text;
40214 break;
40215 default:
40216 bad_subwidg_type("GetText()", true, ty);
40217 break;
40218 }
40219 if(str)
40220 {
40221 auto aptr = get_register(sarg1) / 10000;
40222 if(ArrayH::setArray(aptr, *str, true) == SH::_Overflow)
40223 Z_scripterrlog("Array supplied to 'subscreenwidget->GetText()' not large enough,"
40224 " and couldn't be resized!\n");
40225 }
40226 }
40227 break;
40228 }
40229 case SUBWIDG_TY_SETTEXT:
40230 {
40231 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SetText"))
40232 {
40233 std::string* str = nullptr;
40234 byte ty = widg->getType();
40235 switch(ty)
40236 {
40237 case widgTEXT:
40238 str = &((SW_Text*)widg)->text;
40239 break;
40240 case widgTEXTBOX:
40241 str = &((SW_TextBox*)widg)->text;
40242 break;
40243 default:
40244 bad_subwidg_type("SetText()", true, ty);
40245 break;
40246 }
40247 if(str)
40248 {
40249 auto aptr = get_register(sarg1) / 10000;
40250 ArrayH::getString(aptr, *str);
40251 }
40252 }
40253 break;
40254 }
40255 default:
40256 {
40257 Z_scripterrlog("Invalid ZASM command %lu reached; terminating\n", scommand);
40258 hit_invalid_zasm = true;
40259 scommand = 0xFFFF;
40260 break;
40261 }
40262 }
40263
1/2
✓ Branch 0 taken 705810512 times.
✗ Branch 1 not taken.
705810512 if(earlyretval == RUNSCRIPT_SELFDELETE)
40264 {
40265 earlyretval = -1;
40266 return RUNSCRIPT_SELFDELETE;
40267 }
40268
1/2
✓ Branch 0 taken 705810512 times.
✗ Branch 1 not taken.
705810512 if (ri->sp >= MAX_SCRIPT_REGISTERS)
40269 {
40270 if (script_funcrun)
40271 return RUNSCRIPT_OK;
40272 Z_scripterrlog("Stack over/underflow caused by command %d!\n", scommand);
40273 }
40274
1/2
✓ Branch 0 taken 705810512 times.
✗ Branch 1 not taken.
705810512 if(hit_invalid_zasm) break;
40275
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 705810512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
705810512 if(script_funcrun && (ri->pc == MAX_PC || scommand == RETURN))
40276 return RUNSCRIPT_OK;
40277
40278 #ifdef _SCRIPT_COUNTER
40279 end_time = std::chrono::steady_clock::now();
40280 script_timer[scommand] += std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time).count();
40281 script_execount[scommand] += 1;
40282 #endif
40283
40284
2/2
✓ Branch 0 taken 705748549 times.
✓ Branch 1 taken 61963 times.
705810512 if (type == ScriptType::Combo)
40285 {
40286
1/2
✓ Branch 0 taken 61963 times.
✗ Branch 1 not taken.
61963 if(combopos_modified == i)
40287 {
40288 //Combo changed! Abort script!
40289 return RUNSCRIPT_OK;
40290 }
40291 61963 }
40292
1/2
✓ Branch 0 taken 705810512 times.
✗ Branch 1 not taken.
705810512 if(increment) ri->pc++;
40293 else increment = true;
40294
1/2
✓ Branch 0 taken 705810512 times.
✗ Branch 1 not taken.
705810512 if ( ri->pc == MAX_PC ) //rolled over from overflow?
40295 {
40296 Z_scripterrlog("Script PC overflow! Too many ZASM lines?\n");
40297 ri->pc = 0;
40298 scommand = 0xFFFF;
40299 }
40300
40301
1/2
✓ Branch 0 taken 705810512 times.
✗ Branch 1 not taken.
705810512 if(earlyretval > -1) //Should this be below the 'commands_run += 1'? Unsure. -Em
40302 {
40303 auto v = earlyretval;
40304 earlyretval = -1;
40305 return earlyretval;
40306 }
40307
40308 // If running a JIT compiled script, we're only here to do a few commands.
40309 705810512 commands_run += 1;
40310
3/4
✓ Branch 0 taken 705810512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3093775 times.
✓ Branch 3 taken 702716737 times.
705810512 if (is_jitted && commands_run == jitted_uncompiled_command_count) break;
40311 }
40312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 712307653 times.
712307653 if(script_funcrun) return RUNSCRIPT_OK;
40313
40314
2/2
✓ Branch 0 taken 712307642 times.
✓ Branch 1 taken 11 times.
712307653 if(!scriptCanSave)
40315 11 scriptCanSave=true;
40316
40317
2/2
✓ Branch 0 taken 710442888 times.
✓ Branch 1 taken 1864765 times.
712307653 if(scommand == WAITDRAW)
40318 {
40319
3/9
✓ Branch 0 taken 1852097 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 188 times.
✓ Branch 6 taken 12480 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
1864765 switch(type)
40320 {
40321 case ScriptType::Global:
40322 case ScriptType::Player:
40323 case ScriptType::DMap:
40324 case ScriptType::OnMap:
40325 case ScriptType::ScriptedPassiveSubscreen:
40326 case ScriptType::ScriptedActiveSubscreen:
40327 case ScriptType::Screen:
40328 case ScriptType::Combo:
40329 1852097 FFCore.waitdraw(type, i) = true;
40330 1852097 break;
40331
40332 case ScriptType::Item:
40333 {
40334 if (!get_qr(qr_NOITEMWAITDRAW))
40335 {
40336 FFCore.waitdraw(ScriptType::Item, i) = true;
40337 }
40338 break;
40339 }
40340
40341 case ScriptType::NPC:
40342 {
40343 //enemy *wp = (enemy*)guys.spr(i);
40344 //wp->waitdraw = 1;
40345 guys.spr(GuyH::getNPCIndex(i))->waitdraw = 1;
40346 break;
40347 }
40348 case ScriptType::Lwpn:
40349 {
40350 188 Lwpns.spr(LwpnH::getLWeaponIndex(i))->waitdraw = 1;
40351 188 break;
40352 }
40353
40354 case ScriptType::Ewpn:
40355 {
40356 12480 Ewpns.spr(EwpnH::getEWeaponIndex(i))->waitdraw = 1;
40357 12480 break;
40358 }
40359 case ScriptType::ItemSprite:
40360 {
40361 items.spr(ItemH::getItemIndex(i))->waitdraw = 1;
40362 break;
40363 }
40364
40365 case ScriptType::FFC:
40366 {
40367 if ( !(get_qr(qr_NOFFCWAITDRAW)) )
40368 {
40369 FFCore.waitdraw(ScriptType::FFC, i) = true;
40370 }
40371 else
40372 {
40373 Z_scripterrlog("Waitdraw cannot be used in script type: %s\n", "ffc, with Script Rule 'No FFC Waitdraw() enabled!");
40374 }
40375 break;
40376 }
40377
40378 case ScriptType::Generic:
40379 case ScriptType::GenericFrozen:
40380 case ScriptType::EngineSubscreen:
40381 //No Waitdraw
40382 break;
40383
40384 default:
40385 Z_scripterrlog("Waitdraw cannot be used in script type: %s\n", ScriptTypeToString(type));
40386 break;
40387 }
40388 1864765 }
40389
40390
2/2
✓ Branch 0 taken 70468 times.
✓ Branch 1 taken 712237185 times.
712307653 if(scommand == 0xFFFF) //Quit/command list end reached/bad command
40391 {
40392
8/11
✗ Branch 0 not taken.
✓ Branch 1 taken 836 times.
✓ Branch 2 taken 1253 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6681 times.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 1009 times.
✓ Branch 9 taken 60621 times.
✓ Branch 10 taken 40 times.
70468 switch(type)
40393 {
40394 case ScriptType::FFC:
40395 {
40396 6681 tmpscr->ffcs[i].script = 0;
40397 6681 auto& data = get_script_engine_data(type, i);
40398 6681 data.doscript = false;
40399 }
40400 6681 break;
40401
40402 case ScriptType::Screen:
40403 18 tmpscr->script = 0;
40404 case ScriptType::Global:
40405 case ScriptType::Player:
40406 case ScriptType::DMap:
40407 case ScriptType::OnMap:
40408 case ScriptType::ScriptedActiveSubscreen:
40409 case ScriptType::ScriptedPassiveSubscreen:
40410 case ScriptType::EngineSubscreen:
40411 case ScriptType::Combo:
40412 {
40413 1271 auto& data = get_script_engine_data(type, i);
40414 1271 data.doscript = false;
40415 }
40416 1271 break;
40417
40418 case ScriptType::Generic:
40419 user_scripts[script].quit();
40420 break;
40421
40422 case ScriptType::GenericFrozen:
40423 10 gen_active_doscript = 0;
40424 10 break;
40425
40426 case ScriptType::Item:
40427 {
40428
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 bool collect = ( ( i < 1 ) || (i == COLLECT_SCRIPT_ITEM_ZERO) );
40429
3/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
1009 int new_i = ( collect ) ? (( i != COLLECT_SCRIPT_ITEM_ZERO ) ? (i * -1) : 0) : i;
40430 1009 auto& data = get_script_engine_data(ScriptType::Item, i);
40431
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 if ( !collect )
40432 {
40433
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 815 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
815 if ( (itemsbuf[i].flags&ITEM_PASSIVESCRIPT) && game->item[i] ) itemsbuf[i].script = 0; //Quit perpetual scripts, too.
40434 815 data.doscript = 0;
40435 815 data.ref.Clear();
40436 815 }
40437 else
40438 {
40439 194 data.doscript = 0;
40440 194 data.ref.Clear();
40441 }
40442 1009 data.initialized = false;
40443 1009 break;
40444 }
40445 case ScriptType::NPC:
40446 {
40447 guys.spr(GuyH::getNPCIndex(i))->doscript = 0;
40448 guys.spr(GuyH::getNPCIndex(i))->weaponscript = 0;
40449 guys.spr(GuyH::getNPCIndex(i))->initialised = 0;
40450 break;
40451 }
40452 case ScriptType::Lwpn:
40453 {
40454 60621 Lwpns.spr(LwpnH::getLWeaponIndex(i))->doscript = 0;
40455 60621 Lwpns.spr(LwpnH::getLWeaponIndex(i))->weaponscript = 0;
40456 60621 Lwpns.spr(LwpnH::getLWeaponIndex(i))->initialised = 0;
40457 60621 break;
40458 }
40459 case ScriptType::Ewpn:
40460 {
40461
40462 836 Ewpns.spr(EwpnH::getEWeaponIndex(i))->doscript = 0;
40463 836 Ewpns.spr(EwpnH::getEWeaponIndex(i))->weaponscript = 0;
40464 836 Ewpns.spr(EwpnH::getEWeaponIndex(i))->initialised = 0;
40465 836 break;
40466 }
40467 case ScriptType::ItemSprite:
40468 {
40469 40 items.spr(ItemH::getItemIndex(i))->doscript = 0;
40470 40 items.spr(ItemH::getItemIndex(i))->script = 0;
40471 40 items.spr(ItemH::getItemIndex(i))->initialised = 0;
40472 40 break;
40473 }
40474 }
40475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70468 times.
70468 if(!no_dealloc)
40476
3/3
✓ Branch 0 taken 69441 times.
✓ Branch 1 taken 1009 times.
✓ Branch 2 taken 18 times.
70468 switch(type)
40477 {
40478 case ScriptType::Item:
40479 {
40480
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 bool collect = ( ( i < 1 ) || (i == COLLECT_SCRIPT_ITEM_ZERO) );
40481
3/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
1009 int new_i = ( collect ) ? (( i != COLLECT_SCRIPT_ITEM_ZERO ) ? (i * -1) : 0) : i;
40482 1009 FFScript::deallocateAllScriptOwned(ScriptType::Item, new_i);
40483 1009 break;
40484 }
40485
40486 case ScriptType::Screen:
40487 {
40488 18 FFScript::deallocateAllScriptOwned(ScriptType::Screen, 0);
40489 18 break;
40490 }
40491
40492 default:
40493 69441 FFScript::deallocateAllScriptOwned(type, i);
40494 69441 break;
40495 70468 }
40496
40497 70468 return RUNSCRIPT_STOPPED;
40498 }
40499 else
40500 712237185 ri->pc++;
40501
40502 712237185 return RUNSCRIPT_OK;
40503 712307661 }
40504
40505 script_data* load_scrdata(ScriptType type, word script, int32_t i)
40506 {
40507 switch(type)
40508 {
40509 case ScriptType::FFC:
40510 return ffscripts[script];
40511 case ScriptType::NPC:
40512 return guyscripts[guys.spr(GuyH::getNPCIndex(i))->script];
40513 case ScriptType::Lwpn:
40514 return lwpnscripts[Lwpns.spr(LwpnH::getLWeaponIndex(i))->weaponscript];
40515 case ScriptType::Ewpn:
40516 return ewpnscripts[Ewpns.spr(EwpnH::getEWeaponIndex(i))->weaponscript];
40517 case ScriptType::ItemSprite:
40518 return itemspritescripts[items.spr(ItemH::getItemIndex(i))->script];
40519 case ScriptType::Item:
40520 return itemscripts[script];
40521 case ScriptType::Global:
40522 return globalscripts[script];
40523 case ScriptType::Generic:
40524 case ScriptType::GenericFrozen:
40525 return genericscripts[script];
40526 case ScriptType::Player:
40527 return playerscripts[script];
40528 case ScriptType::DMap:
40529 return dmapscripts[script];
40530 case ScriptType::OnMap:
40531 case ScriptType::ScriptedActiveSubscreen:
40532 case ScriptType::ScriptedPassiveSubscreen:
40533 return dmapscripts[script];
40534 case ScriptType::Screen:
40535 return screenscripts[script];
40536 case ScriptType::Combo:
40537 return comboscripts[script];
40538 case ScriptType::EngineSubscreen:
40539 return subscreenscripts[script];
40540 }
40541 return nullptr;
40542 }
40543
40544 //This keeps ffc scripts running beyond the first frame.
40545 7299692 int32_t ffscript_engine(const bool preload)
40546 {
40547
2/2
✓ Branch 0 taken 7284151 times.
✓ Branch 1 taken 15541 times.
7299692 if(preload)
40548 {
40549 15541 throwGenScriptEvent(GENSCR_EVENT_FFC_PRELOAD);
40550 15541 }
40551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7299692 times.
7299692 if (!FFCore.system_suspend[susptFFCSCRIPTS])
40552 {
40553 //run screen script, first
40554 //zprint("Screen Script Preload? %s \n", ( tmpscr->preloadscript ? "true" : "false"));
40555
4/4
✓ Branch 0 taken 15541 times.
✓ Branch 1 taken 7284151 times.
✓ Branch 2 taken 15528 times.
✓ Branch 3 taken 7268623 times.
7299692 if(( preload && tmpscr->preloadscript) || !preload )
40556 {
40557
2/2
✓ Branch 0 taken 6969052 times.
✓ Branch 1 taken 315112 times.
7284164 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
40558 {
40559
3/4
✓ Branch 0 taken 9269 times.
✓ Branch 1 taken 305843 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9269 times.
315112 if ( tmpscr->script > 0 && FFCore.doscript(ScriptType::Screen) )
40560 {
40561 9269 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
40562 9269 }
40563 315112 }
40564 7284164 }
40565 7299692 word c = tmpscr->numFFC();
40566
2/2
✓ Branch 0 taken 229221135 times.
✓ Branch 1 taken 7299692 times.
236520827 for(word i = 0; i < c; i++)
40567 {
40568
2/2
✓ Branch 0 taken 4717304 times.
✓ Branch 1 taken 224503831 times.
229221135 if(tmpscr->ffcs[i].script == 0)
40569 224503831 continue;
40570
40571
4/4
✓ Branch 0 taken 6096 times.
✓ Branch 1 taken 4711208 times.
✓ Branch 2 taken 1703 times.
✓ Branch 3 taken 4393 times.
4717304 if(preload && !(tmpscr->ffcs[i].flags&ffPRELOAD))
40572 4393 continue;
40573
40574
4/4
✓ Branch 0 taken 4708352 times.
✓ Branch 1 taken 4559 times.
✓ Branch 2 taken 4677052 times.
✓ Branch 3 taken 31300 times.
4712911 if((tmpscr->ffcs[i].flags&ffIGNOREHOLDUP)==0 && Hero.getHoldClk()>0)
40575 31300 continue;
40576
40577 4681611 ZScriptVersion::RunScript(ScriptType::FFC, tmpscr->ffcs[i].script, i);
40578 4681611 }
40579 7299692 }
40580
40581
40582 7299692 return 0;
40583 }
40584
40585
40586
40587 ///----------------------------------------------------------------------------------------------------
40588
40589 225 void FFScript::user_files_init()
40590 {
40591
2/2
✓ Branch 0 taken 57600 times.
✓ Branch 1 taken 225 times.
57825 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
40592 {
40593 57600 script_files[q].clear();
40594 57600 }
40595 225 }
40596
40597 225 void FFScript::user_dirs_init()
40598 {
40599
2/2
✓ Branch 0 taken 57600 times.
✓ Branch 1 taken 225 times.
57825 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
40600 {
40601 57600 script_dirs[q].clear();
40602 57600 }
40603 225 }
40604 346 void FFScript::user_objects_init()
40605 {
40606
2/2
✓ Branch 0 taken 74302808 times.
✓ Branch 1 taken 346 times.
74303154 for(int32_t q = 0; q < MAX_USER_OBJECTS; ++q)
40607 {
40608 74302808 script_objects[q].clear_nodestruct();
40609 74302808 }
40610 346 max_valid_object = 0;
40611 346 }
40612
40613 225 void FFScript::user_stacks_init()
40614 {
40615
2/2
✓ Branch 0 taken 57600 times.
✓ Branch 1 taken 225 times.
57825 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
40616 {
40617 57600 script_stacks[q].clear();
40618 57600 }
40619 225 }
40620
40621 408 void FFScript::user_rng_init()
40622 {
40623
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 408 times.
104856 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
40624 {
40625 104448 replay_register_rng(&script_rnggens[q]);
40626 104448 script_rngs[q].clear();
40627 104448 script_rngs[q].set_gen(&script_rnggens[q]);
40628 104448 }
40629 408 }
40630
40631 225 void FFScript::user_paldata_init()
40632 {
40633
2/2
✓ Branch 0 taken 57600 times.
✓ Branch 1 taken 225 times.
57825 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
40634 {
40635 57600 script_paldatas[q].clear();
40636 57600 }
40637 225 }
40638
40639 2 int32_t FFScript::get_free_file(bool skipError)
40640 {
40641
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
40642 {
40643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!script_files[q].reserved)
40644 {
40645 2 script_files[q].reserved = true;
40646 2 return q+1; //1-indexed; 0 is null value
40647 }
40648 }
40649 if(!skipError) Z_scripterrlog("get_free_file() could not find a valid free file pointer!\n");
40650 return 0;
40651 2 }
40652
40653 int32_t FFScript::get_free_object(bool skipError)
40654 {
40655 for(int32_t q = 0; q < MAX_USER_OBJECTS; ++q)
40656 {
40657 if(!script_objects[q].reserved)
40658 {
40659 script_objects[q].reserved = true;
40660 if(q >= max_valid_object)
40661 max_valid_object = q+1;
40662 return q+1; //1-indexed; 0 is null value
40663 }
40664 }
40665 if(!skipError) Z_scripterrlog("get_free_object() could not find a valid free object pointer!\n");
40666 return 0;
40667 }
40668
40669 int32_t FFScript::get_free_directory(bool skipError)
40670 {
40671 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
40672 {
40673 if(!script_dirs[q].reserved)
40674 {
40675 script_dirs[q].reserved = true;
40676 return q+1; //1-indexed; 0 is null value
40677 }
40678 }
40679 if(!skipError) Z_scripterrlog("get_free_directory() could not find a valid free directory pointer!\n");
40680 return 0;
40681 }
40682
40683 22 int32_t FFScript::get_free_rng(bool skipError)
40684 {
40685
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
40686 {
40687
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 22 times.
31 if(!script_rngs[q].reserved)
40688 {
40689 22 script_rngs[q].reserved = true;
40690 22 return q+1; //1-indexed; 0 is null value
40691 }
40692 9 }
40693 if(!skipError) Z_scripterrlog("get_free_rng() could not find a valid free rng pointer!\n");
40694 return 0;
40695 22 }
40696
40697 int32_t FFScript::get_free_paldata(bool skipError)
40698 {
40699 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
40700 {
40701 if (!script_paldatas[q].reserved)
40702 {
40703 script_paldatas[q].reserved = true;
40704 return q+1; //1-indexed; 0 is null value
40705 }
40706 }
40707 if (!skipError) Z_scripterrlog("get_free_paldata() could not find a valid free paldata pointer!\n");
40708 return 0;
40709 }
40710
40711 int32_t FFScript::get_free_stack(bool skipError)
40712 {
40713 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
40714 {
40715 if(!script_stacks[q].reserved)
40716 {
40717 script_stacks[q].reserved = true;
40718 return q+1; //1-indexed; 0 is null value
40719 }
40720 }
40721 if(!skipError) Z_scripterrlog("get_free_stack() could not find a valid free stack pointer!\n");
40722 return 0;
40723 }
40724
40725 // Gotten from 'https://fileinfo.com/filetypes/executable'
40726
187/376
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 115 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 115 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 115 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 115 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 115 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 115 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 115 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 115 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 115 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 115 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 115 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 115 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 115 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 115 times.
✗ Branch 37 not taken.
✓ Branch 38 taken 115 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 115 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 115 times.
✗ Branch 43 not taken.
✓ Branch 44 taken 115 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 115 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 115 times.
✗ Branch 49 not taken.
✓ Branch 50 taken 115 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 115 times.
✗ Branch 53 not taken.
✓ Branch 54 taken 115 times.
✗ Branch 55 not taken.
✓ Branch 56 taken 115 times.
✗ Branch 57 not taken.
✓ Branch 58 taken 115 times.
✗ Branch 59 not taken.
✓ Branch 60 taken 115 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 115 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 115 times.
✗ Branch 65 not taken.
✓ Branch 66 taken 115 times.
✗ Branch 67 not taken.
✓ Branch 68 taken 115 times.
✗ Branch 69 not taken.
✓ Branch 70 taken 115 times.
✗ Branch 71 not taken.
✓ Branch 72 taken 115 times.
✗ Branch 73 not taken.
✓ Branch 74 taken 115 times.
✗ Branch 75 not taken.
✓ Branch 76 taken 115 times.
✗ Branch 77 not taken.
✓ Branch 78 taken 115 times.
✗ Branch 79 not taken.
✓ Branch 80 taken 115 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 115 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 115 times.
✗ Branch 85 not taken.
✓ Branch 86 taken 115 times.
✗ Branch 87 not taken.
✓ Branch 88 taken 115 times.
✗ Branch 89 not taken.
✓ Branch 90 taken 115 times.
✗ Branch 91 not taken.
✓ Branch 92 taken 115 times.
✗ Branch 93 not taken.
✓ Branch 94 taken 115 times.
✗ Branch 95 not taken.
✓ Branch 96 taken 115 times.
✗ Branch 97 not taken.
✓ Branch 98 taken 115 times.
✗ Branch 99 not taken.
✓ Branch 100 taken 115 times.
✗ Branch 101 not taken.
✓ Branch 102 taken 115 times.
✗ Branch 103 not taken.
✓ Branch 104 taken 115 times.
✗ Branch 105 not taken.
✓ Branch 106 taken 115 times.
✗ Branch 107 not taken.
✓ Branch 108 taken 115 times.
✗ Branch 109 not taken.
✓ Branch 110 taken 115 times.
✗ Branch 111 not taken.
✓ Branch 112 taken 115 times.
✗ Branch 113 not taken.
✓ Branch 114 taken 115 times.
✗ Branch 115 not taken.
✓ Branch 116 taken 115 times.
✗ Branch 117 not taken.
✓ Branch 118 taken 115 times.
✗ Branch 119 not taken.
✓ Branch 120 taken 115 times.
✗ Branch 121 not taken.
✓ Branch 122 taken 115 times.
✗ Branch 123 not taken.
✓ Branch 124 taken 115 times.
✗ Branch 125 not taken.
✓ Branch 126 taken 115 times.
✗ Branch 127 not taken.
✓ Branch 128 taken 115 times.
✗ Branch 129 not taken.
✓ Branch 130 taken 115 times.
✗ Branch 131 not taken.
✓ Branch 132 taken 115 times.
✗ Branch 133 not taken.
✓ Branch 134 taken 115 times.
✗ Branch 135 not taken.
✓ Branch 136 taken 115 times.
✗ Branch 137 not taken.
✓ Branch 138 taken 115 times.
✗ Branch 139 not taken.
✓ Branch 140 taken 115 times.
✗ Branch 141 not taken.
✓ Branch 142 taken 115 times.
✗ Branch 143 not taken.
✓ Branch 144 taken 115 times.
✗ Branch 145 not taken.
✓ Branch 146 taken 115 times.
✗ Branch 147 not taken.
✓ Branch 148 taken 115 times.
✗ Branch 149 not taken.
✓ Branch 150 taken 115 times.
✗ Branch 151 not taken.
✓ Branch 152 taken 115 times.
✗ Branch 153 not taken.
✓ Branch 154 taken 115 times.
✗ Branch 155 not taken.
✓ Branch 156 taken 115 times.
✗ Branch 157 not taken.
✓ Branch 158 taken 115 times.
✗ Branch 159 not taken.
✓ Branch 160 taken 115 times.
✗ Branch 161 not taken.
✓ Branch 162 taken 115 times.
✗ Branch 163 not taken.
✓ Branch 164 taken 115 times.
✗ Branch 165 not taken.
✓ Branch 166 taken 115 times.
✗ Branch 167 not taken.
✓ Branch 168 taken 115 times.
✗ Branch 169 not taken.
✓ Branch 170 taken 115 times.
✗ Branch 171 not taken.
✓ Branch 172 taken 115 times.
✗ Branch 173 not taken.
✓ Branch 174 taken 115 times.
✗ Branch 175 not taken.
✓ Branch 176 taken 115 times.
✗ Branch 177 not taken.
✓ Branch 178 taken 115 times.
✗ Branch 179 not taken.
✓ Branch 180 taken 115 times.
✗ Branch 181 not taken.
✓ Branch 182 taken 115 times.
✗ Branch 183 not taken.
✓ Branch 184 taken 115 times.
✗ Branch 185 not taken.
✓ Branch 186 taken 115 times.
✗ Branch 187 not taken.
✓ Branch 188 taken 115 times.
✗ Branch 189 not taken.
✓ Branch 190 taken 115 times.
✗ Branch 191 not taken.
✓ Branch 192 taken 115 times.
✗ Branch 193 not taken.
✓ Branch 194 taken 115 times.
✗ Branch 195 not taken.
✓ Branch 196 taken 115 times.
✗ Branch 197 not taken.
✓ Branch 198 taken 115 times.
✗ Branch 199 not taken.
✓ Branch 200 taken 115 times.
✗ Branch 201 not taken.
✓ Branch 202 taken 115 times.
✗ Branch 203 not taken.
✓ Branch 204 taken 115 times.
✗ Branch 205 not taken.
✓ Branch 206 taken 115 times.
✗ Branch 207 not taken.
✓ Branch 208 taken 115 times.
✗ Branch 209 not taken.
✓ Branch 210 taken 115 times.
✗ Branch 211 not taken.
✓ Branch 212 taken 115 times.
✗ Branch 213 not taken.
✓ Branch 214 taken 115 times.
✗ Branch 215 not taken.
✓ Branch 216 taken 115 times.
✗ Branch 217 not taken.
✓ Branch 218 taken 115 times.
✗ Branch 219 not taken.
✓ Branch 220 taken 115 times.
✗ Branch 221 not taken.
✓ Branch 222 taken 115 times.
✗ Branch 223 not taken.
✓ Branch 224 taken 115 times.
✗ Branch 225 not taken.
✓ Branch 226 taken 115 times.
✗ Branch 227 not taken.
✓ Branch 228 taken 115 times.
✗ Branch 229 not taken.
✓ Branch 230 taken 115 times.
✗ Branch 231 not taken.
✓ Branch 232 taken 115 times.
✗ Branch 233 not taken.
✓ Branch 234 taken 115 times.
✗ Branch 235 not taken.
✓ Branch 236 taken 115 times.
✗ Branch 237 not taken.
✓ Branch 238 taken 115 times.
✗ Branch 239 not taken.
✓ Branch 240 taken 115 times.
✗ Branch 241 not taken.
✓ Branch 242 taken 115 times.
✗ Branch 243 not taken.
✓ Branch 244 taken 115 times.
✗ Branch 245 not taken.
✓ Branch 246 taken 115 times.
✗ Branch 247 not taken.
✓ Branch 248 taken 115 times.
✗ Branch 249 not taken.
✓ Branch 250 taken 115 times.
✗ Branch 251 not taken.
✓ Branch 252 taken 115 times.
✗ Branch 253 not taken.
✓ Branch 254 taken 115 times.
✗ Branch 255 not taken.
✓ Branch 256 taken 115 times.
✗ Branch 257 not taken.
✓ Branch 258 taken 115 times.
✗ Branch 259 not taken.
✓ Branch 260 taken 115 times.
✗ Branch 261 not taken.
✓ Branch 262 taken 115 times.
✗ Branch 263 not taken.
✓ Branch 264 taken 115 times.
✗ Branch 265 not taken.
✓ Branch 266 taken 115 times.
✗ Branch 267 not taken.
✓ Branch 268 taken 115 times.
✗ Branch 269 not taken.
✓ Branch 270 taken 115 times.
✗ Branch 271 not taken.
✓ Branch 272 taken 115 times.
✗ Branch 273 not taken.
✓ Branch 274 taken 115 times.
✗ Branch 275 not taken.
✓ Branch 276 taken 115 times.
✗ Branch 277 not taken.
✓ Branch 278 taken 115 times.
✗ Branch 279 not taken.
✓ Branch 280 taken 115 times.
✗ Branch 281 not taken.
✓ Branch 282 taken 115 times.
✗ Branch 283 not taken.
✓ Branch 284 taken 115 times.
✗ Branch 285 not taken.
✓ Branch 286 taken 115 times.
✗ Branch 287 not taken.
✓ Branch 288 taken 115 times.
✗ Branch 289 not taken.
✓ Branch 290 taken 115 times.
✗ Branch 291 not taken.
✓ Branch 292 taken 115 times.
✗ Branch 293 not taken.
✓ Branch 294 taken 115 times.
✗ Branch 295 not taken.
✓ Branch 296 taken 115 times.
✗ Branch 297 not taken.
✓ Branch 298 taken 115 times.
✗ Branch 299 not taken.
✓ Branch 300 taken 115 times.
✗ Branch 301 not taken.
✓ Branch 302 taken 115 times.
✗ Branch 303 not taken.
✓ Branch 304 taken 115 times.
✗ Branch 305 not taken.
✓ Branch 306 taken 115 times.
✗ Branch 307 not taken.
✓ Branch 308 taken 115 times.
✗ Branch 309 not taken.
✓ Branch 310 taken 115 times.
✗ Branch 311 not taken.
✓ Branch 312 taken 115 times.
✗ Branch 313 not taken.
✓ Branch 314 taken 115 times.
✗ Branch 315 not taken.
✓ Branch 316 taken 115 times.
✗ Branch 317 not taken.
✓ Branch 318 taken 115 times.
✗ Branch 319 not taken.
✓ Branch 320 taken 115 times.
✗ Branch 321 not taken.
✓ Branch 322 taken 115 times.
✗ Branch 323 not taken.
✓ Branch 324 taken 115 times.
✗ Branch 325 not taken.
✓ Branch 326 taken 115 times.
✗ Branch 327 not taken.
✓ Branch 328 taken 115 times.
✗ Branch 329 not taken.
✓ Branch 330 taken 115 times.
✗ Branch 331 not taken.
✓ Branch 332 taken 115 times.
✗ Branch 333 not taken.
✓ Branch 334 taken 115 times.
✗ Branch 335 not taken.
✓ Branch 336 taken 115 times.
✗ Branch 337 not taken.
✓ Branch 338 taken 115 times.
✗ Branch 339 not taken.
✓ Branch 340 taken 115 times.
✗ Branch 341 not taken.
✓ Branch 342 taken 115 times.
✗ Branch 343 not taken.
✓ Branch 344 taken 115 times.
✗ Branch 345 not taken.
✓ Branch 346 taken 115 times.
✗ Branch 347 not taken.
✓ Branch 348 taken 115 times.
✗ Branch 349 not taken.
✓ Branch 350 taken 115 times.
✗ Branch 351 not taken.
✓ Branch 352 taken 115 times.
✗ Branch 353 not taken.
✓ Branch 354 taken 115 times.
✗ Branch 355 not taken.
✓ Branch 356 taken 115 times.
✗ Branch 357 not taken.
✓ Branch 358 taken 115 times.
✗ Branch 359 not taken.
✓ Branch 360 taken 115 times.
✗ Branch 361 not taken.
✓ Branch 362 taken 115 times.
✗ Branch 363 not taken.
✓ Branch 364 taken 115 times.
✗ Branch 365 not taken.
✓ Branch 366 taken 115 times.
✗ Branch 367 not taken.
✓ Branch 368 taken 115 times.
✗ Branch 369 not taken.
✓ Branch 370 taken 115 times.
✗ Branch 371 not taken.
✓ Branch 372 taken 115 times.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
115 static std::set<std::string> banned_extensions = {".xlm",".caction",".8ck", ".actc",".a6p", ".m3g",".run",".workflow",".otm",".apk",".fxp",".73k",".0xe",".exe",".cmd",".jsx",".scar",".wcm",".jar",".ebs2",".ipa",".xap",".ba_",".ac",".bin",".vlx",".icd",".elf",".xbap",".89k",".widget",".a7r",".ex_",".zl9",".cgi",".scr",".coffee",".ahk",".plsc",".air",".ear",".app",".scptd",".xys",".hms",".cyw",".ebm",".pwc",".xqt",".msl",".seed",".vexe",".ebs",".mcr",".gpu",".celx",".wsh",".frs",".vxp",".action",".com",".out",".gadget",".command",".script",".rfu",".tcp",".widget",".ex4",".bat",".cof",".phar",".rxe",".scb",".ms",".isu",".fas",".mlx",".gpe",".mcr",".mrp",".u3p",".js",".acr",".epk",".exe1",".jsf",".rbf",".rgs",".vpm",".ecf",".hta",".dld",".applescript",".prg",".pyc",".spr",".nexe",".server",".appimage",".pyo",".dek",".mrc",".fpi",".rpj",".iim",".vbs",".pif",".mel",".scpt",".csh",".paf",".ws",".mm",".acc",".ex5",".mac",".plx",".snap",".ps1",".vdo",".mxe",".gs",".osx",".sct",".wiz",".x86",".e_e",".fky",".prg",".fas",".azw2",".actm",".cel",".tiapp",".thm",".kix",".wsf",".vbe",".lo",".ls",".tms",".ezs",".ds",".n",".esh",".vbscript",".arscript",".qit",".pex",".dxl",".wpm",".s2a",".sca",".prc",".shb",".rbx",".jse",".beam",".udf",".mem",".kx",".ksh",".rox",".upx",".ms",".mam",".btm",".es",".asb",".ipf",".mio",".sbs",".hpf",".ita",".eham",".ezt",".dmc",".qpx",".ore",".ncl",".exopc",".smm",".pvd",".ham",".wpk"};
40727
40728 // Any extension other than banned ones, including no extension, is allowed.
40729 2 bool validate_userfile_extension(string const& path)
40730 {
40731
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 std::string ext = std::filesystem::path(path).extension().string();
40732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 return banned_extensions.find(ext) == banned_extensions.end();
40733 2 }
40734
40735 2 bool FFScript::get_scriptfile_path(char* buf, const char* path)
40736 {
40737
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 while((path[0] == '/' || path[0] == '\\') && path[0]) ++path;
40738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(path[0])
40739 2 sprintf(buf, "%s%c%s", qst_files_path, PATH_SLASH, path);
40740 else sprintf(buf, "%s", qst_files_path);
40741 2 return true;
40742 }
40743
40744 void check_file_error(int32_t ref)
40745 {
40746 if(user_file* f = checkFile(ref, "", true, true))
40747 {
40748 int32_t err = ferror(f->file);
40749 if(err != 0)
40750 {
40751 Z_scripterrlog("File with UID '%ld' encountered an error.\n", ref);
40752 Z_scripterrlog("File error: %s\n", strerror(err));
40753 }
40754 }
40755 }
40756
40757 2 void FFScript::do_fopen(const bool v, const char* f_mode)
40758 {
40759 2 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
40760 2 string filename_str;
40761
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 ArrayH::getString(arrayptr, filename_str, 512);
40762
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 regulate_path(filename_str);
40763 2 ri->d[rEXP1] = 0L; //Presume failure; update to 10000L on success
40764
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!valid_file(filename_str))
40765 {
40766 Z_scripterrlog("Path '%s' empty or points to a directory; must point to a file!\n",filename_str.c_str());
40767 return;
40768 }
40769
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!validate_userfile_extension(filename_str))
40770 {
40771 Z_scripterrlog("Cannot open/create file with extension '%s'.\n", get_ext(filename_str).c_str());
40772 return;
40773 }
40774
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(filename_str.find("../") != string::npos
40775
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 || filename_str.find("..\\") != string::npos)
40776 {
40777 Z_scripterrlog("Error: Script attempted to go up a directory in file load '%s'\n", filename_str.c_str());
40778 return;
40779 }
40780 2 char buf[2048+1] = {0};
40781 2 FFCore.get_scriptfile_path(buf, filename_str.c_str());
40782
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 user_file* f = checkFile(ri->fileref, "Open()", false, true);
40783
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!f) //auto-allocate
40784 {
40785
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 ri->fileref = get_free_file();
40786
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 f = checkFile(ri->fileref, "Open()", false, true);
40787 2 }
40788 2 ri->d[rEXP2] = ri->fileref; //Returns to the variable!
40789
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(f)
40790 {
40791
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 f->close(); //Close the old FILE* before overwriting it!
40792 2 bool create = false;
40793
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 for(int32_t q = 0; f_mode[q]; ++q)
40794 {
40795
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
4 if(f_mode[q] == 'w' || f_mode[q] == 'a')
40796 {
40797 1 create = true;
40798 1 break;
40799 }
40800 3 }
40801
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 if(!create || create_path(buf))
40802 {
40803
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 f->file = fopen(buf, f_mode);
40804
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 fflush(f->file);
40805
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 zc_chmod(buf, SCRIPT_FILE_MODE);
40806
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 f->setPath(buf);
40807 //r+; read-write, will not create if does not exist, will not delete content if does exist.
40808 //w+; read-write, will create if does not exist, will delete all content if does exist.
40809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(f->file)
40810 {
40811 ri->d[rEXP1] = 10000L; //Success
40812 return;
40813 }
40814 1 }
40815 else
40816 {
40817
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 Z_scripterrlog("Script failed to create directories for file path '%s'.\n", filename_str.c_str());
40818 1 return;
40819 }
40820 1 }
40821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 }
40822
40823 void FFScript::do_fremove()
40824 {
40825 if(user_file* f = checkFile(ri->fileref, "Remove()", true))
40826 {
40827 zprint2("Removing file %d\n", ri->fileref);
40828 ri->d[rEXP1] = f->do_remove() ? 0L : 10000L;
40829 }
40830 else ri->d[rEXP1] = 0L;
40831 }
40832
40833 void FFScript::do_fclose()
40834 {
40835 if(user_file* f = checkFile(ri->fileref, "Close()", false, true))
40836 {
40837 f->close();
40838 }
40839 //No else. If invalid, no error is thrown.
40840 }
40841
40842 void FFScript::do_allocate_file()
40843 {
40844 //Get a file and return it
40845 ri->fileref = get_free_file();
40846 ri->d[rEXP2] = ri->fileref; //Return to ptr
40847 ri->d[rEXP1] = (ri->d[rEXP2] == 0 ? 0L : 10000L);
40848 }
40849
40850 1 void FFScript::do_deallocate_file()
40851 {
40852 1 user_file* f = checkFile(ri->fileref, "Free()", false, true);
40853
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(f) f->clear();
40854 1 }
40855
40856 void FFScript::do_file_isallocated() //Returns true if file is allocated
40857 {
40858 user_file* f = checkFile(ri->fileref, "isAllocated()", false, true);
40859 ri->d[rEXP1] = (f) ? 10000L : 0L;
40860 }
40861
40862 void FFScript::do_file_isvalid() //Returns true if file is allocated and has an open FILE*
40863 {
40864 user_file* f = checkFile(ri->fileref, "isValid()", true, true);
40865 ri->d[rEXP1] = (f) ? 10000L : 0L;
40866 }
40867
40868 1 void FFScript::do_fflush()
40869 {
40870 1 ri->d[rEXP1] = 0L;
40871
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(user_file* f = checkFile(ri->fileref, "Flush()", true))
40872 {
40873 if(!fflush(f->file))
40874 ri->d[rEXP1] = 10000L;
40875 check_file_error(ri->fileref);
40876 }
40877 1 }
40878
40879 void FFScript::do_file_readchars()
40880 {
40881 if(user_file* f = checkFile(ri->fileref, "ReadChars()", true))
40882 {
40883 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
40884 int32_t count = get_register(sarg2) / 10000;
40885 if(count == 0) return;
40886 int32_t arrayptr = get_register(sarg1) / 10000;
40887 ArrayManager am(arrayptr);
40888 int32_t sz = am.size();
40889 if(sz <= 0)
40890 return;
40891 if(pos >= sz)
40892 {
40893 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "ReadChars()", arrayptr);
40894 return;
40895 }
40896 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
40897 int32_t limit = pos+count;
40898 char c;
40899 word q;
40900 ri->d[rEXP1] = 0;
40901 for(q = pos; q < limit; ++q)
40902 {
40903 c = fgetc(f->file);
40904 if(feof(f->file) || ferror(f->file))
40905 break;
40906 if(c <= 0)
40907 break;
40908 am.set(q,c * 10000L);
40909 ++ri->d[rEXP1]; //Don't count nullchar towards length
40910 }
40911 if(q >= limit)
40912 {
40913 --q;
40914 --ri->d[rEXP1];
40915 ungetc(am.get(q), f->file); //Put the character back before overwriting it
40916 }
40917 am.set(q,0); //Force null-termination
40918 ri->d[rEXP1] *= 10000L;
40919 check_file_error(ri->fileref);
40920 return;
40921 }
40922 ri->d[rEXP1] = 0L;
40923 }
40924 void FFScript::do_file_readbytes()
40925 {
40926 if(user_file* f = checkFile(ri->fileref, "ReadBytes()", true))
40927 {
40928 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
40929 int32_t count = get_register(sarg2) / 10000;
40930 if(count == 0) return;
40931 int32_t arrayptr = get_register(sarg1) / 10000;
40932 ArrayManager am(arrayptr);
40933 int32_t sz = am.size();
40934 if(sz <= 0)
40935 return;
40936 if(pos >= sz)
40937 {
40938 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "ReadBytes()", arrayptr);
40939 return;
40940 }
40941 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
40942 std::vector<uint8_t> data(count);
40943 ri->d[rEXP1] = 10000L * fread((void*)&(data[0]), 1, count, f->file);
40944 for(int32_t q = 0; q < count; ++q)
40945 {
40946 am.set(q+pos, 10000L * data[q]);
40947 }
40948 check_file_error(ri->fileref);
40949 return;
40950 }
40951 ri->d[rEXP1] = 0L;
40952 }
40953 void FFScript::do_file_readstring()
40954 {
40955 if(user_file* f = checkFile(ri->fileref, "ReadString()", true))
40956 {
40957 int32_t arrayptr = get_register(sarg1) / 10000;
40958 ArrayManager am(arrayptr);
40959 int32_t sz = am.size();
40960 if(sz <= 0)
40961 return;
40962 int32_t limit = sz;
40963 int32_t c;
40964 word q;
40965 ri->d[rEXP1] = 0;
40966 for(q = 0; q < limit; ++q)
40967 {
40968 c = fgetc(f->file);
40969 if(feof(f->file) || ferror(f->file))
40970 break;
40971 if(c <= 0)
40972 break;
40973 am.set(q,c * 10000L);
40974 ++ri->d[rEXP1]; //Don't count nullchar towards length
40975 if(c == '\n')
40976 {
40977 ++q;
40978 break;
40979 }
40980 }
40981 if(q >= limit)
40982 {
40983 --q;
40984 --ri->d[rEXP1];
40985 ungetc(am.get(q), f->file); //Put the character back before overwriting it
40986 }
40987 am.set(q,0); //Force null-termination
40988 ri->d[rEXP1] *= 10000L;
40989 check_file_error(ri->fileref);
40990 return;
40991 }
40992 ri->d[rEXP1] = 0L;
40993 }
40994 void FFScript::do_file_readints()
40995 {
40996 if(user_file* f = checkFile(ri->fileref, "ReadInts()", true))
40997 {
40998 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
40999 int32_t count = get_register(sarg2) / 10000;
41000 if(count == 0) return;
41001 int32_t arrayptr = get_register(sarg1) / 10000;
41002 ArrayManager am(arrayptr);
41003 int32_t sz = am.size();
41004 if(sz <= 0)
41005 return;
41006 if(pos >= sz)
41007 {
41008 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "ReadInts()", arrayptr);
41009 return;
41010 }
41011 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
41012
41013 std::vector<int32_t> data(count);
41014 ri->d[rEXP1] = 10000L * fread((void*)&(data[0]), 4, count, f->file);
41015 for(int32_t q = 0; q < count; ++q)
41016 {
41017 am.set(q+pos,data[q]);
41018 }
41019 check_file_error(ri->fileref);
41020 return;
41021 }
41022 ri->d[rEXP1] = 0L;
41023 }
41024 void FFScript::do_file_writechars()
41025 {
41026 if(user_file* f = checkFile(ri->fileref, "WriteChars()", true))
41027 {
41028 int32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
41029 int32_t count = get_register(sarg2) / 10000;
41030 if(count == 0) return;
41031 if(count == -1 || count > (MAX_ZC_ARRAY_SIZE-pos)) count = MAX_ZC_ARRAY_SIZE-pos;
41032 int32_t arrayptr = get_register(sarg1) / 10000;
41033 string output;
41034 ArrayH::getString(arrayptr, output, count, pos);
41035 uint32_t q = 0;
41036 for(; q < output.length(); ++q)
41037 {
41038 if(fputc(output[q], f->file)<0)
41039 break;
41040 }
41041 ri->d[rEXP1] = q * 10000L;
41042 check_file_error(ri->fileref);
41043 return;
41044 }
41045 ri->d[rEXP1] = 0L;
41046 }
41047
41048 void FFScript::do_file_writebytes()
41049 {
41050 if(user_file* f = checkFile(ri->fileref, "WriteBytes()", true))
41051 {
41052 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
41053 int32_t arg = get_register(sarg2) / 10000;
41054 if(arg == 0) return;
41055 uint32_t count = ((arg<0 || unsigned(arg) >(MAX_ZC_ARRAY_SIZE - pos)) ? MAX_ZC_ARRAY_SIZE - pos : unsigned(arg));
41056 int32_t arrayptr = get_register(sarg1) / 10000;
41057 string output;
41058 ArrayManager am(arrayptr);
41059 if(am.invalid()) return;
41060 int32_t sz = am.size();
41061 if(sz <= 0)
41062 return;
41063 if(pos >= sz)
41064 {
41065 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "WriteBytes()", arrayptr);
41066 return;
41067 }
41068 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
41069 std::vector<uint8_t> data(count);
41070 for(uint32_t q = 0; q < count; ++q)
41071 {
41072 data[q] = am.get(q+pos) / 10000;
41073 }
41074 ri->d[rEXP1] = 10000L * fwrite((const void*)&(data[0]), 1, count, f->file);
41075 check_file_error(ri->fileref);
41076 return;
41077 }
41078 ri->d[rEXP1] = 0L;
41079 }
41080 279 void FFScript::do_file_writestring()
41081 {
41082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(user_file* f = checkFile(ri->fileref, "WriteString()", true))
41083 {
41084 int32_t arrayptr = get_register(sarg1) / 10000;
41085 string output;
41086 ArrayH::getString(arrayptr, output, ZSCRIPT_MAX_STRING_CHARS);
41087 uint32_t q = 0;
41088 for(; q < output.length(); ++q)
41089 {
41090 if(fputc(output[q], f->file)<0)
41091 break;
41092 }
41093 ri->d[rEXP1] = q * 10000L;
41094 check_file_error(ri->fileref);
41095 return;
41096 }
41097 279 ri->d[rEXP1] = 0L;
41098 279 }
41099 void FFScript::do_file_writeints()
41100 {
41101 if(user_file* f = checkFile(ri->fileref, "WriteInts()", true))
41102 {
41103 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
41104 int32_t count = get_register(sarg2) / 10000;
41105 if(count == 0) return;
41106 int32_t arrayptr = get_register(sarg1) / 10000;
41107 ArrayManager am(arrayptr);
41108 if(am.invalid()) return;
41109 int32_t sz = am.size();
41110 if(sz <= 0)
41111 return;
41112 if(pos >= sz)
41113 {
41114 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "WriteInts()", arrayptr);
41115 return;
41116 }
41117
41118 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
41119 std::vector<int32_t> data(count);
41120 for(int32_t q = 0; q < count; ++q)
41121 {
41122 data[q] = am.get(q+pos);
41123 }
41124 ri->d[rEXP1] = 10000L * fwrite((const void*)&(data[0]), 4, count, f->file);
41125 check_file_error(ri->fileref);
41126 return;
41127 }
41128 ri->d[rEXP1] = 0L;
41129 }
41130
41131 void FFScript::do_file_getchar()
41132 {
41133 if(user_file* f = checkFile(ri->fileref, "GetChar()", true))
41134 {
41135 ri->d[rEXP1] = fgetc(f->file) * 10000L;
41136 check_file_error(ri->fileref);
41137 return;
41138 }
41139 ri->d[rEXP1] = -10000L; //-1 == EOF; error value
41140 }
41141 void FFScript::do_file_putchar()
41142 {
41143 if(user_file* f = checkFile(ri->fileref, "PutChar()", true))
41144 {
41145 int32_t c = get_register(sarg1) / 10000;
41146 if(char(c) != c)
41147 {
41148 Z_scripterrlog("Invalid character val %d passed to PutChar(); value will overflow.", c);
41149 c = char(c);
41150 }
41151 ri->d[rEXP1] = fputc(c, f->file) * 10000L;
41152 check_file_error(ri->fileref);
41153 return;
41154 }
41155 ri->d[rEXP1] = -10000L; //-1 == EOF; error value
41156 }
41157 void FFScript::do_file_ungetchar()
41158 {
41159 if(user_file* f = checkFile(ri->fileref, "UngetChar()", true))
41160 {
41161 int32_t c = get_register(sarg1) / 10000;
41162 if(char(c) != c)
41163 {
41164 Z_scripterrlog("Invalid character val %d passed to UngetChar(); value will overflow.", c);
41165 c = char(c);
41166 }
41167 ri->d[rEXP1] = ungetc(c,f->file) * 10000L;
41168 check_file_error(ri->fileref);
41169 return;
41170 }
41171 ri->d[rEXP1] = -10000L; //-1 == EOF; error value
41172 }
41173
41174 void FFScript::do_file_seek()
41175 {
41176 if(user_file* f = checkFile(ri->fileref, "Seek()", true))
41177 {
41178 int32_t pos = get_register(sarg1); //NOT /10000 -V
41179 int32_t origin = get_register(sarg2) ? SEEK_CUR : SEEK_SET;
41180 ri->d[rEXP1] = fseek(f->file, pos, origin) ? 0L : 10000L;
41181 check_file_error(ri->fileref);
41182 return;
41183 }
41184 ri->d[rEXP1] = 0;
41185 }
41186 void FFScript::do_file_rewind()
41187 {
41188 if(user_file* f = checkFile(ri->fileref, "Rewind()", true))
41189 {
41190 //fseek(f->file, 0L, SEEK_END);
41191 rewind(f->file);
41192 check_file_error(ri->fileref);
41193 }
41194 }
41195 void FFScript::do_file_clearerr()
41196 {
41197 if(user_file* f = checkFile(ri->fileref, "ClearError()", true))
41198 {
41199 clearerr(f->file);
41200 }
41201 }
41202
41203 void FFScript::do_file_geterr()
41204 {
41205 if(user_file* f = checkFile(ri->fileref, "GetError()", true))
41206 {
41207 int32_t err = ferror(f->file);
41208 int32_t arrayptr = get_register(sarg1) / 10000;
41209 if(err)
41210 {
41211 string error = strerror(err);
41212 ArrayH::setArray(arrayptr, error);
41213 }
41214 else
41215 {
41216 ArrayH::setArray(arrayptr, "\0");
41217 }
41218 }
41219 }
41220 ///----------------------------------------------------------------------------------------------------
41221 //Directory
41222
41223 void FFScript::do_directory_get()
41224 {
41225 if(user_dir* dr = checkDir(ri->directoryref, "GetFilename()", true))
41226 {
41227 int32_t indx = get_register(sarg1) / 10000L;
41228 int32_t arrayptr = get_register(sarg2) / 10000L;
41229 char buf[2048] = {0};
41230 set_register(sarg1, dr->get(indx, buf) ? 10000L : 0L);
41231 if(ArrayH::setArray(arrayptr, string(buf)) == SH::_Overflow)
41232 Z_scripterrlog("Array supplied to 'directory->GetFilename()' not large enough\n");
41233 }
41234 else set_register(sarg1, 0L);
41235 }
41236
41237 void FFScript::do_directory_reload()
41238 {
41239 if(user_dir* dr = checkDir(ri->directoryref, "Reload()", true))
41240 {
41241 dr->refresh();
41242 }
41243 }
41244
41245 void FFScript::do_directory_free()
41246 {
41247 if(user_dir* dr = checkDir(ri->directoryref, "Free()", true))
41248 {
41249 dr->clear();
41250 }
41251 }
41252
41253 ///----------------------------------------------------------------------------------------------------
41254
41255
41256 void FFScript::do_write_bitmap()
41257 {
41258 // for ( int32_t q = 0; q < 16; q++)
41259 // zprint("do_write_bitmap stack sp+%d: %d\n", q, SH::read_stack(ri->sp+q));
41260 int32_t arrayptr = get_register(sarg2) / 10000;
41261 string filename_str;
41262
41263 ArrayH::getString(arrayptr, filename_str, 512);
41264 int32_t ref = ri->bitmapref-10;
41265 // zprint("WriteBitmap() filename is %s\n",filename_str.c_str());
41266 // zprint("WriteBitmap ri->bitmapref is: %d\n",ref );
41267 if ( ref <= 0 )
41268 {
41269 if (ref == -2 )
41270 {
41271 save_bitmap(filename_str.c_str(), framebuf, RAMpal);
41272 // zprint("Wrote image file %s\n",filename_str.c_str());
41273 }
41274 else
41275 {
41276 Z_scripterrlog("WriteBitmap() failed to write image file %s\n",filename_str.c_str());
41277 }
41278 }
41279 else if ( ref >= 7 )
41280 {
41281 if ( scb.script_created_bitmaps[ref].u_bmp )
41282 {
41283 save_bitmap(filename_str.c_str(), scb.script_created_bitmaps[ri->bitmapref-10].u_bmp, RAMpal);
41284 // zprint("Wrote image file %s\n",filename_str.c_str());
41285 }
41286 else
41287 {
41288 Z_scripterrlog("WriteBitmap() failed to write image file %s\n",filename_str.c_str());
41289 }
41290 }
41291 else
41292 {
41293 if ( zscriptDrawingRenderTarget->GetBitmapPtr(ref) )
41294 {
41295 save_bitmap(filename_str.c_str(), zscriptDrawingRenderTarget->GetBitmapPtr(ref), RAMpal);
41296 // zprint("Wrote image file %s\n",filename_str.c_str());
41297 }
41298 else
41299 {
41300 Z_scripterrlog("WriteBitmap() failed to write image file %s\n",filename_str.c_str());
41301 }
41302 }
41303 }
41304
41305 void FFScript::set_sarg1(int32_t v)
41306 {
41307 set_register(sarg1, v);
41308 }
41309
41310 //script_bitmaps scb;
41311
41312 125 int32_t FFScript::do_allocate_bitmap()
41313 {
41314 125 return FFCore.get_free_bitmap();
41315 }
41316 void FFScript::do_isvalidbitmap()
41317 {
41318 int32_t UID = get_register(sarg1);
41319 //zprint("isValidBitmap() bitmap pointer value is %d\n", UID);
41320 if ( UID <= 0 ) set_register(sarg1, 0);
41321 else if ( scb.script_created_bitmaps[UID-10].u_bmp )
41322 set_register(sarg1, 10000);
41323 else set_register(sarg1, 0);
41324 }
41325 42 void FFScript::do_isallocatedbitmap()
41326 {
41327 42 int32_t UID = get_register(sarg1);
41328 //zprint("isAllocatedBitmap() bitmap pointer value is %d\n", UID);
41329
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 41 times.
42 if ( UID <= 0 ) set_register(sarg1, 0);
41330 else
41331 {
41332 41 set_register(sarg1, (scb.script_created_bitmaps[UID-10].reserved()) ? 10000L : 0L);
41333 /*
41334 UID-=10;
41335 if ( UID <= highest_valid_user_bitmap() || UID < firstUserGeneratedBitmap)
41336 set_register(sarg1, 10000);
41337 else set_register(sarg1, 0);
41338 */
41339
41340 }
41341 42 }
41342
41343 225 void FFScript::user_bitmaps_init()
41344 {
41345 225 scb.clear();
41346 225 }
41347
41348 146 int32_t FFScript::do_create_bitmap()
41349 {
41350 //zprint("Begin running FFCore.do_create_bitmap()\n");
41351 //CreateBitmap(h,w)
41352 146 int32_t w = (ri->d[rINDEX2] / 10000);
41353 146 int32_t h = (ri->d[rINDEX]/10000);
41354
1/2
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
146 if ( get_qr(qr_OLDCREATEBITMAP_ARGS) )
41355 {
41356 //flip height and width
41357 h = h ^ w;
41358 w = h ^ w;
41359 h = h ^ w;
41360 }
41361
41362 146 return create_user_bitmap_ex(h,w,8);
41363 }
41364
41365 146 int32_t FFScript::create_user_bitmap_ex(int32_t w, int32_t h, int32_t d = 8)
41366 {
41367 146 int32_t id = get_free_bitmap();
41368
1/2
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
146 if ( id > 0 )
41369 {
41370 146 user_bitmap* bmp = &(scb.script_created_bitmaps[id-10]);
41371 146 bmp->width = w;
41372 146 bmp->height = h;
41373 146 bmp->depth = d;
41374 146 bmp->u_bmp = create_bitmap_ex(d,w,h);
41375 146 clear_bitmap(bmp->u_bmp);
41376 146 }
41377 146 return id;
41378 }
41379
41380 604925 BITMAP* FFScript::GetScriptBitmap(int32_t id, bool skipError)
41381 {
41382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604925 times.
604925 switch(id)
41383 {
41384 case rtSCREEN:
41385 case rtBMP0:
41386 case rtBMP1:
41387 case rtBMP2:
41388 case rtBMP3:
41389 case rtBMP4:
41390 case rtBMP5:
41391 case rtBMP6: //old system bitmaps (render targets)
41392 {
41393 return zscriptDrawingRenderTarget->GetBitmapPtr(id);
41394 }
41395 default:
41396 {
41397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604925 times.
604925 if(user_bitmap* b = checkBitmap(id+10, NULL, true, skipError))
41398 {
41399 604925 return b->u_bmp;
41400 }
41401 else return NULL;
41402 }
41403 }
41404 604925 }
41405
41406 271 int32_t FFScript::get_free_bitmap(bool skipError)
41407 {
41408 271 user_bitmap* bmps = scb.script_created_bitmaps;
41409
1/2
✓ Branch 0 taken 26577 times.
✗ Branch 1 not taken.
26577 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
41410 {
41411
2/2
✓ Branch 0 taken 26306 times.
✓ Branch 1 taken 271 times.
26577 if(!bmps[q].reserved())
41412 {
41413 271 bmps[q].reserve();
41414 271 return q+10;
41415 }
41416 26306 }
41417 if(!skipError) Z_scripterrlog("get_free_bitmap() could not find a valid free bitmap pointer!\n");
41418 return 0;
41419 271 }
41420
41421 void FFScript::do_deallocate_bitmap()
41422 {
41423 if(isSystemBitref(ri->bitmapref))
41424 {
41425 return; //Don't attempt to deallocate system bitmaps!
41426 }
41427 user_bitmap* b = checkBitmap(ri->bitmapref, "Free()", false, true);
41428 if(b)
41429 {
41430 b->free_obj();
41431 }
41432 }
41433
41434 146 bool FFScript::isSystemBitref(int32_t ref)
41435 {
41436
1/2
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
146 switch(ref-10)
41437 {
41438 case rtSCREEN:
41439 case rtBMP0:
41440 case rtBMP1:
41441 case rtBMP2:
41442 case rtBMP3:
41443 case rtBMP4:
41444 case rtBMP5:
41445 case rtBMP6:
41446 return true;
41447 }
41448 146 return false;
41449 146 }
41450
41451 ///----------------------------------------------------------------------------------------------------
41452
41453 void FFScript::set_screenwarpReturnY(mapscr *m, int32_t d, int32_t value)
41454 {
41455 int32_t y = vbound(value, 0, 255); //should be screen hight max, except that we may be able to move the subscreen.
41456 m->warpreturny[d] = y;
41457 }
41458
41459 void FFScript::set_screendoor(mapscr *m, int32_t d, int32_t value)
41460 {
41461 int32_t dr = vbound(d,0,3);
41462 int32_t doortype = vbound(value,0,14);
41463 m->door[dr] = doortype;
41464 }
41465
41466
41467 void FFScript::set_screenenemy(mapscr *m, int32_t index, int32_t value)
41468 {
41469 int32_t enem_indx = vbound(index,0,9);
41470 m->enemy[enem_indx] = vbound(value,0,511);
41471 }
41472 void FFScript::set_screenlayeropacity(mapscr *m, int32_t d, int32_t value)
41473 {
41474 int32_t layer = vbound(d,0,6); int32_t op;
41475 if ( value <= 64 ) op = 64;
41476 else op = 128;
41477 m->layeropacity[layer] = op;
41478 }
41479 void FFScript::set_screensecretcombo(mapscr *m, int32_t d, int32_t value)
41480 {
41481 int32_t indx = vbound(value,0,127);
41482 int32_t cmb = vbound(value,0,MAXCOMBOS);
41483 m->secretcombo[indx] = cmb;
41484 }
41485 void FFScript::set_screensecretcset(mapscr *m, int32_t d, int32_t value)
41486 {
41487 int32_t indx = vbound(value,0,127);
41488 int32_t cs = vbound(value,0,15);
41489 m->secretcset[indx] = cs;
41490 }
41491 void FFScript::set_screensecretflag(mapscr *m, int32_t d, int32_t value)
41492 {
41493 int32_t indx = vbound(d,0,127);
41494 int32_t flag = vbound(value,0,MAX_FLAGS);
41495 m->secretflag[indx] = flag;
41496 }
41497 void FFScript::set_screenlayermap(mapscr *m, int32_t d, int32_t value)
41498 {
41499 int32_t layer = vbound(d, MIN_ZQ_LAYER, MAX_ZQ_LAYER);
41500 int32_t mp = vbound(value,0, (map_count-1));
41501 m->layermap[layer] = mp;
41502 }
41503 void FFScript::set_screenlayerscreen(mapscr *m, int32_t d, int32_t value)
41504 {
41505 int32_t layer = vbound(d, MIN_ZQ_LAYER, MAX_ZQ_LAYER);
41506 int32_t sc = vbound(value,0, 0x87);
41507 m->layerscreen[layer] = sc;
41508 }
41509 void FFScript::set_screenpath(mapscr *m, int32_t d, int32_t value)
41510 {
41511 int32_t indx = vbound(d,0,3);
41512 m->path[indx] = value;
41513 }
41514 void FFScript::set_screenwarpReturnX(mapscr *m, int32_t d, int32_t value)
41515 {
41516 int32_t x = vbound(value,0,255);
41517 m->warpreturnx[d] = x;
41518 }
41519
41520
41521 void FFScript::set_screenGuy(mapscr *m, int32_t value)
41522 {
41523 int32_t bloke = vbound(value,0,9);
41524 m->guy = bloke ;
41525 }
41526 void FFScript::set_screenString(mapscr *m, int32_t value)
41527 {
41528 int32_t string = vbound(value, 0, msg_count-1); //Sanity check to keep it within the legal string IDs.
41529 m->str = string;
41530 }
41531 void FFScript::set_screenRoomtype(mapscr *m, int32_t value)
41532 {
41533 int32_t r = vbound(value, rNONE, (rMAX-1));
41534 m->room = r;
41535 }
41536 void FFScript::set_screenEntryX(mapscr *m, int32_t value)
41537 {
41538 int32_t x = vbound(value,0,255);
41539 m->entry_x = x;
41540 }
41541 void FFScript::set_screenEntryY(mapscr *m, int32_t value)
41542 {
41543 int32_t y = vbound(value,0,255);
41544 m->entry_y = y;
41545 }
41546 void FFScript::set_screenitem(mapscr *m, int32_t value)
41547 {
41548 int32_t itm = vbound(value,0,MAXITEMS);
41549 m->item = itm;
41550 }
41551 void FFScript::set_screenundercombo(mapscr *m, int32_t value)
41552 {
41553 int32_t cmb = vbound(value,0,MAXCOMBOS);
41554 m->undercombo = cmb;
41555 }
41556 void FFScript::set_screenundercset(mapscr *m, int32_t value)
41557 {
41558 int32_t cs = vbound(value,0,15);
41559 m->undercset = cs;
41560 }
41561 void FFScript::set_screenatchall(mapscr *m, int32_t value)
41562 {
41563 //What are ALL of the catchalls and their max (used) values?
41564 int32_t ctch = vbound(value, 0, 65535); //It is a word type.
41565 m->catchall = ctch;
41566 }
41567
41568
41569 //One too many inputs here. -Z
41570
41571 1051 int32_t FFScript::GetQuestVersion()
41572 {
41573 1051 return QHeader.zelda_version;
41574 }
41575 720 int32_t FFScript::GetQuestBuild()
41576 {
41577 720 return QHeader.build;
41578 }
41579 int32_t FFScript::GetQuestSectionVersion(int32_t section)
41580 {
41581 return QHeader.zelda_version;
41582 }
41583
41584 int32_t FFScript::GetDefaultWeaponSprite(int32_t wpn_id)
41585 {
41586 switch (wpn_id)
41587 {
41588 case wNone:
41589 return 0;
41590
41591 case wSword: return 0;
41592 case wBeam: return 1;
41593 case wBrang: return 4;
41594 case wBomb: return 9;
41595 case wSBomb: return 75;
41596 case wLitBomb: return 7;
41597 case wLitSBomb: return 8;
41598 case wArrow: return 10;
41599 case wFire: return 12;
41600 case wWhistle: return 45; //blank, unused misc sprite
41601 case wBait: return 14;
41602 case wWand: return 15;
41603 case wMagic: return 16;
41604 case wCatching: return 45; //blank, unused misc sprite
41605 case wWind: return 13;
41606 case wRefMagic: return 16;
41607 case wRefFireball: return 17;
41608 case wRefRock: return 18;
41609 case wHammer: return 25;
41610 case wHookshot: return 26;
41611 case wHSHandle: return 28;
41612 case wHSChain: return 27;
41613 case wSSparkle: return 29;
41614 case wFSparkle: return 32;
41615 case wSmack: return 33;
41616 case wPhantom: return -1;
41617 case wCByrna: return 87;
41618 case wRefBeam: return 1;
41619 case wStomp: return 45; //blank, unused misc sprite
41620 case lwMax: return 45; //blank, unused misc sprite
41621 case wScript1: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 246; else return 0; }
41622 case wScript2: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 247; else return 0; }
41623 case wScript3: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 248; else return 0; }
41624 case wScript4: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 249; else return 0; }
41625 case wScript5: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 250; else return 0; }
41626 case wScript6: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 251; else return 0; }
41627 case wScript7: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 252; else return 0; }
41628 case wScript8: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 253; else return 0; }
41629 case wScript9: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 254; else return 0; }
41630 case wScript10: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 255; else return 0; }
41631
41632 case wIce: return 83;
41633 //Cannot use any of these weapons yet.
41634 //return -1;
41635
41636 case wEnemyWeapons:
41637 case ewFireball: return 17;
41638
41639 case ewArrow: return 19;
41640 case ewBrang: return 4;
41641 case ewSword: return 20;
41642 case ewRock: return 18;
41643 case ewMagic: return 21;
41644 case ewBomb: return 78;
41645 case ewSBomb: return 79;
41646 case ewLitBomb: return 76;
41647 case ewLitSBomb: return 77;
41648 case ewFireTrail: return 80;
41649 case ewFlame: return 35;
41650 case ewWind: return 36;
41651 case ewFlame2: return 81;
41652 case ewFlame2Trail: return 82;
41653 case ewIce: return 83;
41654 case ewFireball2: return 17; //fireball (rising)
41655
41656
41657 default: return -1; //No assign.
41658
41659 }
41660 }
41661
41662 //bitmap->GetPixel()
41663
41664
41665 int32_t FFScript::do_getpixel()
41666 {
41667 int32_t xoffset = 0, yoffset = 0;
41668 int32_t xoff = 0; int32_t yoff = 0;
41669 const bool brokenOffset= ( (get_er(er_BITMAPOFFSET)!=0)
41670 || (get_qr(qr_BITMAPOFFSETFIX)!=0) );
41671
41672 BITMAP *bitty = FFCore.GetScriptBitmap(ri->bitmapref-10);
41673 if(!bitty)
41674 {
41675 bitty = scrollbuf;
41676 }
41677 // draw to screen with subscreen offset
41678 if(!brokenOffset && ri->bitmapref == 10-1 )
41679 {
41680 xoffset = xoff;
41681 yoffset = 56; //should this be -56?
41682 }
41683 else
41684 {
41685 xoffset = 0;
41686 yoffset = 0;
41687 }
41688
41689 int32_t yv = ri->d[rINDEX2]/10000 + yoffset;
41690 int32_t ret = getpixel(bitty, ri->d[rINDEX]/10000, yv); //This is a palette index value.
41691 if(!get_qr(qr_BROKEN_GETPIXEL_VALUE))
41692 ret *= 10000;
41693 return ret;
41694 }
41695
41696 void FFScript::do_bmpcollision()
41697 {
41698 int32_t bmpref = SH::read_stack(ri->sp + 5);
41699 int32_t maskbmpref = SH::read_stack(ri->sp + 4);
41700 int32_t x = SH::read_stack(ri->sp + 3) / 10000;
41701 int32_t y = SH::read_stack(ri->sp + 2) / 10000;
41702 int32_t checkCol = SH::read_stack(ri->sp + 1) / 10000;
41703 int32_t maskCol = SH::read_stack(ri->sp + 0) / 10000;
41704 BITMAP *checkbit = FFCore.GetScriptBitmap(bmpref-10, true);
41705 BITMAP *maskbit = FFCore.GetScriptBitmap(maskbmpref-10, true);
41706 if(!(checkbit && maskbit))
41707 {
41708 set_register(sarg1, -10000);
41709 char buf1[16];
41710 char buf2[16];
41711 zc_itoa(bmpref, buf1);
41712 zc_itoa(maskbmpref, buf2);
41713 Z_scripterrlog("Invalid bitmap%s passed to 'bitmap->CountColor()': %s%s%s\n",
41714 (checkbit || maskbit) ? "" : "s", checkbit ? "" : buf1,
41715 (checkbit || maskbit) ? "" : ", ", maskbit ? "" : buf2);
41716 return;
41717 }
41718 int32_t ret = countColor(checkbit, maskbit, x, y, checkCol, maskCol);
41719 set_register(sarg1, ret*10000);
41720 }
41721
41722
41723 6509791 int32_t FFScript::loadMapData()
41724 {
41725 6509791 int32_t _map = (ri->d[rINDEX] / 10000);
41726 6509791 int32_t _scr = (ri->d[rINDEX2]/10000);
41727
1/2
✓ Branch 0 taken 6509791 times.
✗ Branch 1 not taken.
6509791 int32_t indx = (zc_max((_map)-1,0) * MAPSCRS + _scr);
41728 //zprint("LoadMapData Map Value: %d\n", _map);
41729 //zprint("LoadMapData Screen Value: %d\n", _scr);
41730 //zprint("LoadMapData Indx Value: %d\n", indx);
41731
2/4
✓ Branch 0 taken 6509791 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6509791 times.
6509791 if ( _map < 1 || _map > map_count )
41732 {
41733 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", _map);
41734 ri->mapsref = MAX_SIGNED_32;
41735 }
41736
2/4
✓ Branch 0 taken 6509791 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6509791 times.
6509791 else if ( _scr < 0 || _scr > 129 ) //0x00 to 0x81 -Z
41737 {
41738 Z_scripterrlog("Invalid Screen ID passed to Game->LoadMapData: %d\n", _scr);
41739 ri->mapsref = MAX_SIGNED_32;
41740 }
41741 6509791 else ri->mapsref = indx;
41742 //zprint("LoadMapData Screen set ri->mapsref to: %d\n", ri->mapsref);
41743 6509791 return ri->mapsref;
41744 }
41745
41746
41747 // Called when leaving a screen; deallocate arrays created by FFCs that aren't carried over
41748 6983690 void FFScript::deallocateZScriptArray(const int32_t ptrval)
41749 {
41750
1/2
✓ Branch 0 taken 6983690 times.
✗ Branch 1 not taken.
6983690 if(ptrval == 0) return;
41751
2/4
✓ Branch 0 taken 6983690 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6983690 times.
6983690 if(ptrval==0 || ptrval >= NUM_ZSCRIPT_ARRAYS)
41752 Z_scripterrlog("Script tried to deallocate memory at invalid address %ld\n", ptrval);
41753
1/2
✓ Branch 0 taken 6983690 times.
✗ Branch 1 not taken.
6983690 else if(ptrval<0)
41754 Z_scripterrlog("Script tried to deallocate memory at object-based address %ld\n", ptrval);
41755 else
41756 {
41757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6983690 times.
6983690 if(arrayOwner[ptrval].specOwned) return; //ignore this deallocation
41758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6983690 times.
6983690 if(arrayOwner[ptrval].specCleared) return;
41759 6983690 arrayOwner[ptrval].clear();
41760
41761
1/2
✓ Branch 0 taken 6983690 times.
✗ Branch 1 not taken.
6983690 if(!localRAM[ptrval].Valid())
41762 Z_scripterrlog("Script tried to deallocate memory that was not allocated at address %ld\n", ptrval);
41763 else
41764 6983690 localRAM[ptrval].Clear();
41765 }
41766 6983690 }
41767
41768 433275 int32_t FFScript::get_screen_d(int32_t index1, int32_t index2)
41769 {
41770
3/4
✓ Branch 0 taken 433275 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 433272 times.
433275 if(index2 < 0 || index2 > 7)
41771 {
41772 3 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
41773 3 return 0;
41774 }
41775
41776 433272 return game->screen_d[index1][index2];
41777 433275 }
41778
41779 42105 void FFScript::set_screen_d(int32_t index1, int32_t index2, int32_t val)
41780 {
41781
2/4
✓ Branch 0 taken 42105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42105 times.
42105 if(index2 < 0 || index2 > 7)
41782 {
41783 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
41784 return;
41785 }
41786
41787 42105 game->screen_d[index1][index2] = val;
41788 42105 }
41789
41790 // If scr is currently being used as a layer, return that layer no.
41791 int32_t FFScript::whichlayer(int32_t scr)
41792 {
41793 for(int32_t i = 0; i < 6; i++)
41794 {
41795 if(scr == (tmpscr->layermap[i] - 1) * MAPSCRS + tmpscr->layerscreen[i])
41796 return i;
41797 }
41798
41799 return -1;
41800 }
41801
41802 void FFScript::do_zapout()
41803 {
41804 zapout();
41805 }
41806
41807 void FFScript::do_zapin(){ zapin(); }
41808
41809 void FFScript::do_openscreen() { openscreen(); }
41810 void FFScript::do_closescreen() { closescreen(); }
41811 void FFScript::do_openscreenshape()
41812 {
41813 int32_t shape = get_register(sarg1) / 10000;
41814 if(shape < 0 || shape >= bosMAX)
41815 {
41816 Z_scripterrlog("Invalid shape passed to %s! Valid range %d to %d. Using 'Circle' shape.\n", "Screen->OpeningWipe(int32_t)", 0, bosMAX-1);
41817 shape = bosCIRCLE;
41818 }
41819 openscreen(shape);
41820 }
41821 void FFScript::do_closescreenshape()
41822 {
41823 int32_t shape = get_register(sarg1) / 10000;
41824 if(shape < 0 || shape >= bosMAX)
41825 {
41826 Z_scripterrlog("Invalid shape passed to %s! Valid range %d to %d. Using 'Circle' shape.\n", "Screen->ClosingWipe(int32_t)", 0, bosMAX-1);
41827 shape = bosCIRCLE;
41828 }
41829 closescreen(shape);
41830 }
41831 void FFScript::do_wavyin() { wavyin(); }
41832 void FFScript::do_wavyout() { wavyout(false); }
41833
41834
41835 void FFScript::do_triggersecret(const bool v)
41836 {
41837 int32_t ID = vbound((SH::get_arg(sarg1, v) / 10000), 0, 255);
41838 mapscr *s = tmpscr;
41839 int32_t ft=0, checkflag; //Flag trigger, checked flag temp.
41840 bool putit = true; //Is set false with a mismatch (illegal value input).
41841 //Convert a flag type to a secret type. -Z
41842 switch(ID)
41843 {
41844 case mfANYFIRE:
41845 ft=sBCANDLE;
41846 break;
41847
41848 case mfSTRONGFIRE:
41849 ft=sRCANDLE;
41850 break;
41851
41852 case mfMAGICFIRE:
41853 ft=sWANDFIRE;
41854 break;
41855
41856 case mfDIVINEFIRE:
41857 ft=sDIVINEFIRE;
41858 break;
41859
41860 case mfARROW:
41861 ft=sARROW;
41862 break;
41863
41864 case mfSARROW:
41865 ft=sSARROW;
41866 break;
41867
41868 case mfGARROW:
41869 ft=sGARROW;
41870 break;
41871
41872 case mfSBOMB:
41873 ft=sSBOMB;
41874 break;
41875
41876 case mfBOMB:
41877 ft=sBOMB;
41878 break;
41879
41880 case mfBRANG:
41881 ft=sBRANG;
41882 break;
41883
41884 case mfMBRANG:
41885 ft=sMBRANG;
41886 break;
41887
41888 case mfFBRANG:
41889 ft=sFBRANG;
41890 break;
41891
41892 case mfWANDMAGIC:
41893 ft=sWANDMAGIC;
41894 break;
41895
41896 case mfREFMAGIC:
41897 ft=sREFMAGIC;
41898 break;
41899
41900 case mfREFFIREBALL:
41901 ft=sREFFIREBALL;
41902 break;
41903
41904 case mfSWORD:
41905 ft=sSWORD;
41906 break;
41907
41908 case mfWSWORD:
41909 ft=sWSWORD;
41910 break;
41911
41912 case mfMSWORD:
41913 ft=sMSWORD;
41914 break;
41915
41916 case mfXSWORD:
41917 ft=sXSWORD;
41918 break;
41919
41920 case mfSWORDBEAM:
41921 ft=sSWORDBEAM;
41922 break;
41923
41924 case mfWSWORDBEAM:
41925 ft=sWSWORDBEAM;
41926 break;
41927
41928 case mfMSWORDBEAM:
41929 ft=sMSWORDBEAM;
41930 break;
41931
41932 case mfXSWORDBEAM:
41933 ft=sXSWORDBEAM;
41934 break;
41935
41936 case mfHOOKSHOT:
41937 ft=sHOOKSHOT;
41938 break;
41939
41940 case mfWAND:
41941 ft=sWAND;
41942 break;
41943
41944 case mfHAMMER:
41945 ft=sHAMMER;
41946 break;
41947
41948 case mfSTRIKE:
41949 ft=sSTRIKE;
41950 break;
41951
41952 default:
41953 putit = false;
41954 break;
41955 }
41956 if ( putit )
41957 {
41958 for(int32_t iter=0; iter<2; ++iter)
41959 {
41960 for ( int32_t q = 0; q < 176; q++ )
41961 {
41962 if(iter==1) checkflag=s->sflag[q]; //Placed
41963 else checkflag=combobuf[s->data[q]].flag; //Inherent
41964 Z_message("checkflag is: %d\n", checkflag);
41965 al_trace("checkflag is: %d\n", checkflag);
41966
41967 Z_message("ID is: %ld\n", ID);
41968 al_trace("ID is: %d\n", ID);
41969 //cmbx = COMBOX(q);
41970 ////cmby = COMBOY(q);
41971
41972 //Placed flags
41973 if ( iter == 1 )
41974 {
41975 if ( s->sflag[q] == ID ) {
41976 screen_combo_modify_preroutine(s,q);
41977 s->data[q] = s->secretcombo[ft];
41978 s->cset[q] = s->secretcset[ft];
41979 s->sflag[q] = s->secretflag[ft];
41980 // newflag = s->secretflag[ft];
41981 screen_combo_modify_postroutine(s,q);
41982 }
41983 }
41984 //Inherent flags
41985 else
41986 {
41987 if ( combobuf[s->data[q]].flag == ID ) {
41988 screen_combo_modify_preroutine(s,q);
41989 s->data[q] = s->secretcombo[ft];
41990 s->cset[q] = s->secretcset[ft];
41991 //s->sflag[q] = s->secretflag[ft];
41992 screen_combo_modify_postroutine(s,q);
41993 }
41994
41995 }
41996 }
41997 }
41998 }
41999
42000 }
42001 //NPCData
42002
42003 //NPCData Getter Macros
42004
42005
42006
42007
42008 //NPCData-> Function
42009 #define GET_NPCDATA_FUNCTION_VAR_INT(member) \
42010 { \
42011 int32_t ID = get_register(sarg2) / 10000; \
42012 if(ID < 1 || ID > (MAXGUYS-1)) \
42013 set_register(sarg1, -10000); \
42014 else \
42015 set_register(sarg1, guysbuf[ID].member * 10000); \
42016 }
42017
42018 #define GET_NPCDATA_FUNCTION_VAR_INDEX(member, indexbound) \
42019 { \
42020 int32_t ID = int32_t(ri->d[rINDEX] / 10000);\
42021 int32_t indx = vbound((ri->d[rINDEX2] / 10000), 0, indexbound); \
42022 if(ID < 1 || ID > (MAXGUYS-1)) \
42023 set_register(sarg1, -10000); \
42024 else \
42025 set_register(sarg1, guysbuf[ID].member[indx] * 10000); \
42026 }
42027
42028 #define GET_NPCDATA_FUNCTION_VAR_FLAG(member) \
42029 { \
42030 int32_t ID = int32_t(ri->d[rINDEX] / 10000);\
42031 int32_t flag = int32_t(ri->d[rINDEX2] / 10000);\
42032 if(ID < 1 || ID > (MAXGUYS-1)) \
42033 set_register(sarg1, -10000); \
42034 else \
42035 set_register(sarg1, (guysbuf[ID].member&flag) ? 10000 : 0); \
42036 }
42037
42038 void FFScript::getNPCData_tile(){ GET_NPCDATA_FUNCTION_VAR_INT(tile); } //word
42039 void FFScript::getNPCData_e_height(){ GET_NPCDATA_FUNCTION_VAR_INT(e_height); }
42040 void FFScript::getNPCData_flags(){ GET_NPCDATA_FUNCTION_VAR_INT(flags); } //word
42041 void FFScript::getNPCData_flags2(){ GET_NPCDATA_FUNCTION_VAR_INT(flags2); }
42042 void FFScript::getNPCData_width(){ GET_NPCDATA_FUNCTION_VAR_INT(width); }
42043 void FFScript::getNPCData_height(){ GET_NPCDATA_FUNCTION_VAR_INT(height); }
42044 void FFScript::getNPCData_s_tile(){ GET_NPCDATA_FUNCTION_VAR_INT(s_tile); }
42045 void FFScript::getNPCData_s_width(){ GET_NPCDATA_FUNCTION_VAR_INT(s_width); }
42046 void FFScript::getNPCData_s_height(){ GET_NPCDATA_FUNCTION_VAR_INT(s_height); }
42047 void FFScript::getNPCData_e_tile(){ GET_NPCDATA_FUNCTION_VAR_INT(e_tile); }
42048 void FFScript::getNPCData_e_width(){ GET_NPCDATA_FUNCTION_VAR_INT(e_width); }
42049 void FFScript::getNPCData_hp(){ GET_NPCDATA_FUNCTION_VAR_INT(hp); }
42050 void FFScript::getNPCData_family(){ GET_NPCDATA_FUNCTION_VAR_INT(family); }
42051 void FFScript::getNPCData_cset(){ GET_NPCDATA_FUNCTION_VAR_INT(cset); }
42052 void FFScript::getNPCData_anim(){ GET_NPCDATA_FUNCTION_VAR_INT(anim); }
42053 void FFScript::getNPCData_e_anim(){ GET_NPCDATA_FUNCTION_VAR_INT(e_anim); }
42054 void FFScript::getNPCData_frate(){ GET_NPCDATA_FUNCTION_VAR_INT(frate); }
42055 void FFScript::getNPCData_e_frate(){ GET_NPCDATA_FUNCTION_VAR_INT(e_frate); }
42056 void FFScript::getNPCData_dp(){ GET_NPCDATA_FUNCTION_VAR_INT(dp); }
42057 void FFScript::getNPCData_wdp(){ GET_NPCDATA_FUNCTION_VAR_INT(wdp); }
42058 void FFScript::getNPCData_weapon(){ GET_NPCDATA_FUNCTION_VAR_INT(weapon); }
42059 void FFScript::getNPCData_rate(){ GET_NPCDATA_FUNCTION_VAR_INT(rate); }
42060 void FFScript::getNPCData_hrate(){ GET_NPCDATA_FUNCTION_VAR_INT(hrate); }
42061 void FFScript::getNPCData_step(){ GET_NPCDATA_FUNCTION_VAR_INT(step); }
42062 void FFScript::getNPCData_homing(){ GET_NPCDATA_FUNCTION_VAR_INT(homing); }
42063 void FFScript::getNPCData_grumble(){ GET_NPCDATA_FUNCTION_VAR_INT(grumble); }
42064 void FFScript::getNPCData_item_set(){ GET_NPCDATA_FUNCTION_VAR_INT(item_set); }
42065 void FFScript::getNPCData_bgsfx(){ GET_NPCDATA_FUNCTION_VAR_INT(bgsfx); }
42066 void FFScript::getNPCData_hitsfx(){ GET_NPCDATA_FUNCTION_VAR_INT(hitsfx); }
42067 void FFScript::getNPCData_deadsfx(){ GET_NPCDATA_FUNCTION_VAR_INT(deadsfx); }
42068 void FFScript::getNPCData_xofs(){ GET_NPCDATA_FUNCTION_VAR_INT(xofs); }
42069 void FFScript::getNPCData_yofs(){ GET_NPCDATA_FUNCTION_VAR_INT(yofs); }
42070 void FFScript::getNPCData_zofs(){ GET_NPCDATA_FUNCTION_VAR_INT(zofs); }
42071 void FFScript::getNPCData_hxofs(){ GET_NPCDATA_FUNCTION_VAR_INT(hxofs); }
42072 void FFScript::getNPCData_hyofs(){ GET_NPCDATA_FUNCTION_VAR_INT(hyofs); }
42073 void FFScript::getNPCData_hxsz(){ GET_NPCDATA_FUNCTION_VAR_INT(hxsz); }
42074 void FFScript::getNPCData_hysz(){ GET_NPCDATA_FUNCTION_VAR_INT(hysz); }
42075 void FFScript::getNPCData_hzsz(){ GET_NPCDATA_FUNCTION_VAR_INT(hzsz); }
42076 void FFScript::getNPCData_txsz(){ GET_NPCDATA_FUNCTION_VAR_INT(txsz); }
42077 void FFScript::getNPCData_tysz(){ GET_NPCDATA_FUNCTION_VAR_INT(tysz); }
42078 void FFScript::getNPCData_wpnsprite(){ GET_NPCDATA_FUNCTION_VAR_INT(wpnsprite); }
42079
42080 //NPCData Getters, two inputs, one return, similar to ISSolid
42081
42082 /*
42083
42084 void do_issolid()
42085 {
42086 int32_t x = int32_t(ri->d[rINDEX] / 10000);
42087 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
42088
42089 set_register(sarg1, (_walkflag(x, y, 1) ? 10000 : 0));
42090 }
42091
42092 */
42093
42094
42095
42096
42097
42098
42099 //void FFScript::getNPCData_scriptdefence(){GET_NPCDATA_FUNCTION_VAR_INDEX(scriptdefence)};
42100
42101
42102 void FFScript::getNPCData_defense(){GET_NPCDATA_FUNCTION_VAR_INDEX(defense,int32_t(edefLAST255))};
42103
42104
42105 void FFScript::getNPCData_SIZEflags(){GET_NPCDATA_FUNCTION_VAR_FLAG(SIZEflags);}
42106
42107
42108 void FFScript::getNPCData_misc()
42109 {
42110 int32_t ID = int32_t(ri->d[rINDEX] / 10000); //the enemy ID value
42111 int32_t indx = int32_t(ri->d[rINDEX2] / 10000); //the misc index ID
42112 if ((ID < 1 || ID > 511) || ( indx < 0 || indx > 15 ))
42113 set_register(sarg1, -10000);
42114 switch ( indx )
42115 {
42116 case 0: set_register(sarg1, guysbuf[ID].misc1 * 10000); break;
42117 case 1: set_register(sarg1, guysbuf[ID].misc2 * 10000); break;
42118 case 2: set_register(sarg1, guysbuf[ID].misc3 * 10000); break;
42119 case 3: set_register(sarg1, guysbuf[ID].misc4 * 10000); break;
42120 case 4: set_register(sarg1, guysbuf[ID].misc5 * 10000); break;
42121 case 5: set_register(sarg1, guysbuf[ID].misc6 * 10000); break;
42122 case 6: set_register(sarg1, guysbuf[ID].misc7 * 10000); break;
42123 case 7: set_register(sarg1, guysbuf[ID].misc8 * 10000); break;
42124 case 8: set_register(sarg1, guysbuf[ID].misc9 * 10000); break;
42125 case 9: set_register(sarg1, guysbuf[ID].misc10 * 10000); break;
42126 case 10: set_register(sarg1, guysbuf[ID].misc11 * 10000); break;
42127 case 11: set_register(sarg1, guysbuf[ID].misc12 * 10000); break;
42128 case 12: set_register(sarg1, guysbuf[ID].misc13 * 10000); break;
42129 case 13: set_register(sarg1, guysbuf[ID].misc14 * 10000); break;
42130 case 14: set_register(sarg1, guysbuf[ID].misc15 * 10000); break;
42131 default: set_register(sarg1, -10000); break;
42132 }
42133 }
42134
42135 //NPCData Setters, two inputs, no return; similar to void GetDMapIntro(int32_t DMap, int32_t buffer[]);
42136
42137 /*
42138
42139 void do_getdmapintro(const bool v)
42140 {
42141 int32_t ID = SH::get_arg(sarg1, v) / 10000;
42142 int32_t arrayptr = get_register(sarg2) / 10000;
42143
42144 if(BC::checkDMapID(ID, "Game->GetDMapIntro") != SH::_NoError)
42145 return;
42146
42147 if(ArrayH::setArray(arrayptr, string(DMaps[ID].intro)) == SH::_Overflow)
42148 Z_scripterrlog("Array supplied to 'Game->GetDMapIntro' not large enough\n");
42149 }
42150
42151 */
42152
42153 //NPCData Setter Macros
42154
42155 //Variables for spritedata sp->member
42156
42157
42158
42159 //Functions for NPCData->
42160
42161 #define SET_NPCDATA_FUNCTION_VAR_INT(member, bound) \
42162 { \
42163 int32_t ID = get_register(sarg1) / 10000; \
42164 int32_t val = get_register(sarg2) / 10000; \
42165 if(ID < 1 || ID > (MAXGUYS-1)) \
42166 set_register(sarg1, -10000); \
42167 else \
42168 guysbuf[ID].member = vbound(val,0,bound); \
42169 }
42170
42171
42172
42173 #define SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(member) \
42174 { \
42175 int32_t ID = get_register(sarg1) / 10000; \
42176 int32_t val = get_register(sarg2) / 10000; \
42177 if(ID < 1 || ID > (MAXGUYS-1)) \
42178 set_register(sarg1, -10000); \
42179 else \
42180 guysbuf[ID].member = val; \
42181 }
42182
42183
42184 //SET_NPC_VAR_INDEX(member,value)
42185 #define SET_NPCDATA_FUNCTION_VAR_INDEX(member, val, bound, indexbound) \
42186 { \
42187 int32_t ID = (ri->d[rINDEX]/10000); \
42188 int32_t indx = vbound((ri->d[rINDEX2]/10000),0,indexbound); \
42189 if(ID < 1 || ID > (MAXGUYS-1)) \
42190 return; \
42191 else \
42192 guysbuf[ID].member[indx] = vbound(val,0,bound); \
42193 }
42194
42195 //Special case for flags, three inputs one return
42196 #define SET_NPCDATA_FUNCTION_VAR_FLAG(member, val) \
42197 { \
42198 int32_t ID = (ri->d[rINDEX]/10000); \
42199 int32_t flag = (ri->d[rINDEX2]/10000); \
42200 if(ID < 1 || ID > (MAXGUYS-1)) \
42201 return; \
42202 else \
42203 { \
42204 if ( val != 0 ) guysbuf[ID].member|=flag; \
42205 else guysbuf[ID].member|= ~flag; \
42206 }\
42207 }
42208
42209 void FFScript::setNPCData_flags(){SET_NPCDATA_FUNCTION_VAR_INT(flags,ZS_DWORD);} //word
42210 void FFScript::setNPCData_flags2(){SET_NPCDATA_FUNCTION_VAR_INT(flags2,ZS_DWORD);}
42211 void FFScript::setNPCData_width(){SET_NPCDATA_FUNCTION_VAR_INT(width,ZS_BYTE);}
42212 void FFScript::setNPCData_tile(){SET_NPCDATA_FUNCTION_VAR_INT(tile,ZS_WORD);}
42213 void FFScript::setNPCData_e_height(){SET_NPCDATA_FUNCTION_VAR_INT(e_height,ZS_BYTE);}
42214 void FFScript::setNPCData_height(){SET_NPCDATA_FUNCTION_VAR_INT(height,ZS_BYTE);}
42215 void FFScript::setNPCData_s_tile(){SET_NPCDATA_FUNCTION_VAR_INT(s_tile,ZS_WORD);}
42216 void FFScript::setNPCData_s_width(){SET_NPCDATA_FUNCTION_VAR_INT(s_width,ZS_BYTE);}
42217 void FFScript::setNPCData_s_height(){SET_NPCDATA_FUNCTION_VAR_INT(s_height,ZS_BYTE);}
42218 void FFScript::setNPCData_e_tile(){SET_NPCDATA_FUNCTION_VAR_INT(e_tile,ZS_WORD);}
42219 void FFScript::setNPCData_e_width(){SET_NPCDATA_FUNCTION_VAR_INT(e_width,ZS_BYTE);}
42220 void FFScript::setNPCData_hp(){SET_NPCDATA_FUNCTION_VAR_INT(hp,ZS_SHORT);}
42221 void FFScript::setNPCData_family(){SET_NPCDATA_FUNCTION_VAR_INT(family,ZS_SHORT);}
42222 void FFScript::setNPCData_cset(){SET_NPCDATA_FUNCTION_VAR_INT(cset,ZS_SHORT);}
42223 void FFScript::setNPCData_anim(){SET_NPCDATA_FUNCTION_VAR_INT(anim,ZS_SHORT);}
42224 void FFScript::setNPCData_e_anim(){SET_NPCDATA_FUNCTION_VAR_INT(e_anim,ZS_SHORT);}
42225 void FFScript::setNPCData_frate(){SET_NPCDATA_FUNCTION_VAR_INT(frate,ZS_SHORT);}
42226 void FFScript::setNPCData_e_frate(){SET_NPCDATA_FUNCTION_VAR_INT(e_frate,ZS_SHORT);}
42227 void FFScript::setNPCData_dp(){SET_NPCDATA_FUNCTION_VAR_INT(dp,ZS_SHORT);}
42228 void FFScript::setNPCData_wdp(){SET_NPCDATA_FUNCTION_VAR_INT(wdp,ZS_SHORT);}
42229 void FFScript::setNPCData_weapon(){SET_NPCDATA_FUNCTION_VAR_INT(weapon,ZS_SHORT);}
42230 void FFScript::setNPCData_rate(){SET_NPCDATA_FUNCTION_VAR_INT(rate,ZS_SHORT);}
42231 void FFScript::setNPCData_hrate(){SET_NPCDATA_FUNCTION_VAR_INT(hrate,ZS_SHORT);}
42232 void FFScript::setNPCData_step(){SET_NPCDATA_FUNCTION_VAR_INT(step,ZS_SHORT);}
42233 void FFScript::setNPCData_homing(){SET_NPCDATA_FUNCTION_VAR_INT(homing,ZS_SHORT);}
42234 void FFScript::setNPCData_grumble(){SET_NPCDATA_FUNCTION_VAR_INT(grumble,ZS_SHORT);}
42235 void FFScript::setNPCData_item_set(){SET_NPCDATA_FUNCTION_VAR_INT(item_set,ZS_SHORT);}
42236 void FFScript::setNPCData_bgsfx(){SET_NPCDATA_FUNCTION_VAR_INT(bgsfx,ZS_SHORT);}
42237 void FFScript::setNPCData_hitsfx(){SET_NPCDATA_FUNCTION_VAR_INT(hitsfx,ZS_BYTE);}
42238 void FFScript::setNPCData_deadsfx(){SET_NPCDATA_FUNCTION_VAR_INT(deadsfx,ZS_BYTE);}
42239 void FFScript::setNPCData_xofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(xofs);}
42240 void FFScript::setNPCData_yofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(yofs);}
42241 void FFScript::setNPCData_zofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(zofs);}
42242 void FFScript::setNPCData_hxofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hxofs);}
42243 void FFScript::setNPCData_hyofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hyofs);}
42244 void FFScript::setNPCData_hxsz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hxsz);}
42245 void FFScript::setNPCData_hysz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hysz);}
42246 void FFScript::setNPCData_hzsz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hzsz);}
42247 void FFScript::setNPCData_txsz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(txsz);}
42248 void FFScript::setNPCData_tysz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(tysz);}
42249 void FFScript::setNPCData_wpnsprite(){SET_NPCDATA_FUNCTION_VAR_INT(wpnsprite,511);}
42250
42251 //NPCData Setters, three inputs, no return. works as SetDMapScreenD function
42252
42253
42254
42255
42256
42257
42258
42259 //void FFScript::setNPCData_scriptdefence(){SET_NPCDATA_FUNCTION_VAR_INDEX(scriptdefence);}
42260 void FFScript::setNPCData_defense(int32_t v){SET_NPCDATA_FUNCTION_VAR_INDEX(defense,v, ZS_INT, int32_t(edefLAST255) );}
42261 void FFScript::setNPCData_SIZEflags(int32_t v){SET_NPCDATA_FUNCTION_VAR_FLAG(SIZEflags,v);}
42262 void FFScript::setNPCData_misc(int32_t val)
42263 {
42264 int32_t ID = int32_t(ri->d[rINDEX] / 10000); //the enemy ID value
42265 int32_t indx = int32_t(ri->d[rINDEX2] / 10000); //the misc index ID
42266 if ((ID < 1 || ID > 511) || ( indx < 0 || indx > 15 )) return;
42267 switch ( indx )
42268 {
42269 case 0: guysbuf[ID].misc1 = val; break;
42270 case 1: guysbuf[ID].misc2 = val; break;
42271 case 2: guysbuf[ID].misc3 = val; break;
42272 case 3: guysbuf[ID].misc4 = val; break;
42273 case 4: guysbuf[ID].misc5 = val; break;
42274 case 5: guysbuf[ID].misc6 = val; break;
42275 case 6: guysbuf[ID].misc7 = val; break;
42276 case 7: guysbuf[ID].misc8 = val; break;
42277 case 8: guysbuf[ID].misc9 = val; break;
42278 case 9: guysbuf[ID].misc10 = val; break;
42279 case 10: guysbuf[ID].misc11 = val; break;
42280 case 11: guysbuf[ID].misc12 = val; break;
42281 case 12: guysbuf[ID].misc13 = val; break;
42282 case 13: guysbuf[ID].misc14 = val; break;
42283 case 14: guysbuf[ID].misc15 = val; break;
42284 default: break;
42285 }
42286
42287 };
42288
42289 //ComboData
42290
42291 //Macros
42292
42293 //Are these right? newcombo is *combo_class_buf and the others are *combobuf
42294
42295 //Getters for ComboData 'Type' submembers.
42296 #define GET_COMBODATA_TYPE_INT(member) \
42297 { \
42298 int32_t ID = vbound((get_register(sarg2) / 10000),0,MAXCOMBOS);\
42299 set_register(sarg1, combo_class_buf[combobuf[ID].type].member * 10000); \
42300 }
42301
42302 //this may need additional macros.
42303 //for combo_class_buf[ID].member ?
42304 //I'm not sure which it needs to be at present.
42305
42306 #define GET_COMBODATA_TYPE_INDEX(member, bound) \
42307 { \
42308 int32_t ID = int32_t(vbound((ri->d[rINDEX] / 10000),0,MAXCOMBOS));\
42309 int32_t indx = int32_t(vbound((ri->d[rINDEX2] / 10000), 0, bound));\
42310 set_register(sarg1, combo_class_buf[combobuf[ID].type].member[indx] * 10000); \
42311 }
42312
42313 #define GET_COMBODATA_TYPE_FLAG(member) \
42314 { \
42315 int32_t ID = int32_t(vbound(ri->d[rINDEX] / 10000),0,MAXCOMBOS);\
42316 int32_t flag = int32_t(ri->d[rINDEX2] / 10000);\
42317 set_register(sarg1, (combo_class_buf[combobuf[ID].type].member&flag) ? 10000 : 0); \
42318 }
42319
42320
42321
42322 //Getters for ComboData main members.
42323 #define GET_COMBODATA_VAR_INT(member) \
42324 { \
42325 int32_t ID = vbound( (get_register(sarg2) / 10000), 0, MAXCOMBOS);\
42326 set_register(sarg1, combobuf[ID].member * 10000); \
42327 }
42328
42329 #define GET_COMBODATA_VAR_INDEX(member, bound) \
42330 { \
42331 int32_t ID = int32_t( vbound( (ri->d[rINDEX] / 10000),0,MAXCOMBOS) );\
42332 int32_t indx = int32_t ( vbound( (ri->d[rINDEX2] / 10000),0,bound) );\
42333 set_register(sarg1, combobuf[ID].member[indx] * 10000); \
42334 }
42335
42336 #define GET_COMBODATA_VAR_FLAG(member) \
42337 { \
42338 int32_t ID = int32_t( vbound( ( ri->d[rINDEX] / 10000),0,MAXCOMBOS) );\
42339 int32_t flag = int32_t(ri->d[rINDEX2] / 10000);\
42340 set_register(sarg1, (combobuf[ID].member&flag) ? 10000 : 0); \
42341 }
42342
42343
42344
42345 //ComboData Setter Macros
42346
42347 //Setters for ComboData 'type' submembers.
42348 #define SET_COMBODATA_TYPE_INT(member, bound) \
42349 { \
42350 int32_t ID = get_register(sarg1) / 10000; \
42351 int32_t val = vbound( (get_register(sarg2) / 10000), 0, bound); \
42352 if(ID < 1 || ID > 511) \
42353 set_register(sarg1, -10000); \
42354 else \
42355 combo_class_buf[combobuf[ID].type].member = val; \
42356 }
42357
42358 #define SET_COMBODATA_TYPE_INDEX(member, val, bound, indexbound) \
42359 { \
42360 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
42361 int32_t indx = vbound((ri->d[rINDEX2]/10000),0,indexbound); \
42362 combo_class_buf[combobuf[ID].type].member[indx] = vbound(val,0,bound); \
42363 }
42364
42365 #define SET_COMBODATA_TYPE_FLAG(member, val, bound) \
42366 { \
42367 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
42368 int32_t flag = (ri->d[rINDEX2]/10000); \
42369 combo_class_buf[combobuf[ID].type].member&flag = ((vbound(val,0,bound))!=0); \
42370 \
42371
42372
42373 //Setters for ComboData main members
42374 #define SET_COMBODATA_VAR_INT(member, bound) \
42375 { \
42376 int32_t ID = vbound( (get_register(sarg1) / 10000), 0, MAXCOMBOS); \
42377 int32_t val = vbound((get_register(sarg2) / 10000),0,bound); \
42378 combobuf[ID].member = val; \
42379 }
42380
42381 //SET_NPC_VAR_INDEX(member,value)
42382 #define SET_COMBODATA_VAR_INDEX(member, val, bound, indexbound) \
42383 { \
42384 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
42385 int32_t indx = vbound((ri->d[rINDEX2]/10000),0,indexbound); \
42386 combobuf[ID].member[indx] = vbound(val,0,bound); \
42387 }
42388
42389 //Special case for flags, three inputs one return
42390 #define SET_COMBODATA_VAR_FLAG(member, val, bound) \
42391 { \
42392 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
42393 int32_t flag = (ri->d[rINDEX2]/10000); \
42394 else \
42395 { \
42396 combobuf[ID].member&flag = ((bvound(val,0,bound))!=0); \
42397 }\
42398 }
42399
42400 //Getters
42401
42402 //one input, one return
42403 void FFScript::getComboData_block_enemies(){ GET_COMBODATA_TYPE_INT(block_enemies); } //byte a
42404 void FFScript::getComboData_block_hole(){ GET_COMBODATA_TYPE_INT(block_hole); } //byte b
42405 void FFScript::getComboData_block_trigger(){ GET_COMBODATA_TYPE_INT(block_trigger); } //byte c
42406 void FFScript::getComboData_conveyor_x_speed(){ GET_COMBODATA_TYPE_INT(conveyor_x_speed); } //int16_t e
42407 void FFScript::getComboData_conveyor_y_speed(){ GET_COMBODATA_TYPE_INT(conveyor_y_speed); } //int16_t f
42408 void FFScript::getComboData_create_enemy(){ GET_COMBODATA_TYPE_INT(create_enemy); } //word g
42409 void FFScript::getComboData_create_enemy_when(){ GET_COMBODATA_TYPE_INT(create_enemy_when); } //byte h
42410 void FFScript::getComboData_create_enemy_change(){ GET_COMBODATA_TYPE_INT(create_enemy_change); } //int32_t i
42411 void FFScript::getComboData_directional_change_type(){ GET_COMBODATA_TYPE_INT(directional_change_type); } //byte j
42412 void FFScript::getComboData_distance_change_tiles(){ GET_COMBODATA_TYPE_INT(distance_change_tiles); } //int32_t k
42413 void FFScript::getComboData_dive_item(){ GET_COMBODATA_TYPE_INT(dive_item); } //int16_t l
42414 void FFScript::getComboData_dock(){ GET_COMBODATA_TYPE_INT(dock); } //byte m
42415 void FFScript::getComboData_fairy(){ GET_COMBODATA_TYPE_INT(fairy); } //byte n
42416 void FFScript::getComboData_ff_combo_attr_change(){ GET_COMBODATA_TYPE_INT(ff_combo_attr_change); } //byte o
42417 void FFScript::getComboData_foot_decorations_tile(){ GET_COMBODATA_TYPE_INT(foot_decorations_tile); } //int32_t p
42418 void FFScript::getComboData_foot_decorations_type(){ GET_COMBODATA_TYPE_INT(foot_decorations_type); } //byte q
42419 void FFScript::getComboData_hookshot_grab_point(){ GET_COMBODATA_TYPE_INT(hookshot_grab_point); } //byte r
42420 void FFScript::getComboData_ladder_pass(){ GET_COMBODATA_TYPE_INT(ladder_pass); } //byte s
42421 void FFScript::getComboData_lock_block_type(){ GET_COMBODATA_TYPE_INT(lock_block_type); } //byte t
42422 void FFScript::getComboData_lock_block_change(){ GET_COMBODATA_TYPE_INT(lock_block_change); } //int32_t u
42423 void FFScript::getComboData_magic_mirror_type(){ GET_COMBODATA_TYPE_INT(magic_mirror_type); } //byte v
42424 void FFScript::getComboData_modify_hp_amount(){ GET_COMBODATA_TYPE_INT(modify_hp_amount); } //int16_t w
42425 void FFScript::getComboData_modify_hp_delay(){ GET_COMBODATA_TYPE_INT(modify_hp_delay); } //byte x
42426 void FFScript::getComboData_modify_hp_type(){ GET_COMBODATA_TYPE_INT(modify_hp_type); } //byte y
42427 void FFScript::getComboData_modify_mp_amount(){ GET_COMBODATA_TYPE_INT(modify_mp_amount); } //int16_t z
42428 void FFScript::getComboData_modify_mp_delay(){ GET_COMBODATA_TYPE_INT(modify_mp_delay); } //byte aa
42429 void FFScript::getComboData_modify_mp_type(){ GET_COMBODATA_TYPE_INT(modify_mp_type); } //byte ab
42430 void FFScript::getComboData_no_push_blocks(){ GET_COMBODATA_TYPE_INT(no_push_blocks); } //byte ac
42431 void FFScript::getComboData_overhead(){ GET_COMBODATA_TYPE_INT(overhead); } //byte ad
42432 void FFScript::getComboData_place_enemy(){ GET_COMBODATA_TYPE_INT(place_enemy); } //byte ae
42433 void FFScript::getComboData_push_direction(){ GET_COMBODATA_TYPE_INT(push_direction); } //byte af
42434 void FFScript::getComboData_push_weight(){ GET_COMBODATA_TYPE_INT(push_weight); } //byte ag heavy or not
42435 void FFScript::getComboData_push_wait(){ GET_COMBODATA_TYPE_INT(push_wait); } //byte ah
42436 void FFScript::getComboData_pushed(){ GET_COMBODATA_TYPE_INT(pushed); } //byte ai
42437 void FFScript::getComboData_raft(){ GET_COMBODATA_TYPE_INT(raft); } //byte aj
42438 void FFScript::getComboData_reset_room(){ GET_COMBODATA_TYPE_INT(reset_room); } //byte ak
42439 void FFScript::getComboData_save_point_type(){ GET_COMBODATA_TYPE_INT(save_point_type); } //byte al
42440 void FFScript::getComboData_screen_freeze_type(){ GET_COMBODATA_TYPE_INT(screen_freeze_type); } //byte am
42441
42442 void FFScript::getComboData_secret_combo(){ GET_COMBODATA_TYPE_INT(secret_combo); } //byte an
42443 void FFScript::getComboData_singular(){ GET_COMBODATA_TYPE_INT(singular); } //byte ao
42444 void FFScript::getComboData_slow_movement(){ GET_COMBODATA_TYPE_INT(slow_movement); } //byte ap
42445 void FFScript::getComboData_statue_type(){ GET_COMBODATA_TYPE_INT(statue_type); } //byte aq
42446 void FFScript::getComboData_step_type(){ GET_COMBODATA_TYPE_INT(step_type); } //byte ar
42447 void FFScript::getComboData_step_change_to(){ GET_COMBODATA_TYPE_INT(step_change_to); } //int32_t as
42448 void FFScript::getComboData_strike_remnants(){ GET_COMBODATA_TYPE_INT(strike_remnants); } //int32_t au
42449 void FFScript::getComboData_strike_remnants_type(){ GET_COMBODATA_TYPE_INT(strike_remnants_type); } //byte av
42450 void FFScript::getComboData_strike_change(){ GET_COMBODATA_TYPE_INT(strike_change); } //int32_t aw
42451 void FFScript::getComboData_strike_item(){ GET_COMBODATA_TYPE_INT(strike_item); } //int16_t ax
42452 void FFScript::getComboData_touch_item(){ GET_COMBODATA_TYPE_INT(touch_item); } //int16_t ay
42453 void FFScript::getComboData_touch_stairs(){ GET_COMBODATA_TYPE_INT(touch_stairs); } //byte az
42454 void FFScript::getComboData_trigger_type(){ GET_COMBODATA_TYPE_INT(trigger_type); } //byte ba
42455 void FFScript::getComboData_trigger_sensitive(){ GET_COMBODATA_TYPE_INT(trigger_sensitive); } //byte bb
42456 void FFScript::getComboData_warp_type(){ GET_COMBODATA_TYPE_INT(warp_type); } //byte bc
42457 void FFScript::getComboData_warp_sensitive(){ GET_COMBODATA_TYPE_INT(warp_sensitive); } //byte bd
42458 void FFScript::getComboData_warp_direct(){ GET_COMBODATA_TYPE_INT(warp_direct); } //byte be
42459 void FFScript::getComboData_warp_location(){ GET_COMBODATA_TYPE_INT(warp_location); } //byte bf
42460 void FFScript::getComboData_water(){ GET_COMBODATA_TYPE_INT(water); } //byte bg
42461 void FFScript::getComboData_whistle(){ GET_COMBODATA_TYPE_INT(whistle); } //byte bh
42462 void FFScript::getComboData_win_game(){ GET_COMBODATA_TYPE_INT(win_game); } //byte bi
42463 void FFScript::getComboData_block_weapon_lvl(){ GET_COMBODATA_TYPE_INT(block_weapon_lvl); } //byte bj - max level of weapon to block
42464
42465 void FFScript::getComboData_tile(){ GET_COMBODATA_VAR_INT(tile); } //newcombo, word
42466 void FFScript::getComboData_flip(){ GET_COMBODATA_VAR_INT(flip); } //newcombo byte
42467
42468 void FFScript::getComboData_walk(){ GET_COMBODATA_VAR_INT(walk); } //newcombo byte
42469 void FFScript::getComboData_type(){ GET_COMBODATA_VAR_INT(type); } //newcombo byte
42470 void FFScript::getComboData_csets(){ GET_COMBODATA_VAR_INT(csets); } //newcombo byte
42471 void FFScript::getComboData_frames(){ GET_COMBODATA_VAR_INT(frames); } //newcombo byte
42472 void FFScript::getComboData_speed(){ GET_COMBODATA_VAR_INT(speed); } //newcombo byte
42473 void FFScript::getComboData_nextcombo(){ GET_COMBODATA_VAR_INT(nextcombo); } //newcombo word
42474 void FFScript::getComboData_nextcset(){ GET_COMBODATA_VAR_INT(nextcset); } //newcombo byte
42475 void FFScript::getComboData_flag(){ GET_COMBODATA_VAR_INT(flag); } //newcombo byte
42476 void FFScript::getComboData_skipanim(){ GET_COMBODATA_VAR_INT(skipanim); } //newcombo byte
42477 void FFScript::getComboData_nexttimer(){ GET_COMBODATA_VAR_INT(nexttimer); } //newcombo word
42478 void FFScript::getComboData_skipanimy(){ GET_COMBODATA_VAR_INT(skipanimy); } //newcombo byte
42479 void FFScript::getComboData_animflags(){ GET_COMBODATA_VAR_INT(animflags); } //newcombo byte
42480
42481
42482 //two inputs, one return
42483 void FFScript::getComboData_block_weapon(){ GET_COMBODATA_TYPE_INDEX(block_weapon,32); } //byte array[32] d (ID of LWeapon)
42484 void FFScript::getComboData_expansion(){ GET_COMBODATA_VAR_INDEX(expansion,6); } //newcombo byte, arr[6]
42485 void FFScript::getComboData_strike_weapons(){ GET_COMBODATA_TYPE_INDEX(strike_weapons,32); } //byte at, arr[32]
42486
42487 //Setters, two inputs no returns
42488
42489 void FFScript::setComboData_block_enemies(){ SET_COMBODATA_TYPE_INT(block_enemies,ZS_BYTE); } //byte a
42490 void FFScript::setComboData_block_hole(){ SET_COMBODATA_TYPE_INT(block_hole,ZS_BYTE); } //byte b
42491 void FFScript::setComboData_block_trigger(){ SET_COMBODATA_TYPE_INT(block_trigger,ZS_BYTE); } //byte c
42492 void FFScript::setComboData_conveyor_x_speed(){ SET_COMBODATA_TYPE_INT(conveyor_x_speed,ZS_SHORT); } //int16_t e
42493 void FFScript::setComboData_conveyor_y_speed(){ SET_COMBODATA_TYPE_INT(conveyor_y_speed,ZS_SHORT); } //int16_t f
42494 void FFScript::setComboData_create_enemy(){ SET_COMBODATA_TYPE_INT(create_enemy,ZS_WORD); } //word g
42495 void FFScript::setComboData_create_enemy_when(){ SET_COMBODATA_TYPE_INT(create_enemy_when,ZS_BYTE); } //byte h
42496 void FFScript::setComboData_create_enemy_change(){ SET_COMBODATA_TYPE_INT(create_enemy_change,ZS_LONG); } //int32_t i
42497 void FFScript::setComboData_directional_change_type(){ SET_COMBODATA_TYPE_INT(directional_change_type,ZS_BYTE); } //byte j
42498 void FFScript::setComboData_distance_change_tiles(){ SET_COMBODATA_TYPE_INT(distance_change_tiles,ZS_LONG); } //int32_t k
42499 void FFScript::setComboData_dive_item(){ SET_COMBODATA_TYPE_INT(dive_item,ZS_SHORT); } //int16_t l
42500 void FFScript::setComboData_dock(){ SET_COMBODATA_TYPE_INT(dock,ZS_BYTE); } //byte m
42501 void FFScript::setComboData_fairy(){ SET_COMBODATA_TYPE_INT(fairy,ZS_BYTE); } //byte n
42502 void FFScript::setComboData_ff_combo_attr_change(){ SET_COMBODATA_TYPE_INT(ff_combo_attr_change,ZS_BYTE); } //byte o
42503 void FFScript::setComboData_foot_decorations_tile(){ SET_COMBODATA_TYPE_INT(foot_decorations_tile,ZS_LONG); } //int32_t p
42504 void FFScript::setComboData_foot_decorations_type(){ SET_COMBODATA_TYPE_INT(foot_decorations_type,ZS_BYTE); } //byte q
42505 void FFScript::setComboData_hookshot_grab_point(){ SET_COMBODATA_TYPE_INT(hookshot_grab_point,ZS_BYTE); } //byte r
42506 void FFScript::setComboData_ladder_pass(){ SET_COMBODATA_TYPE_INT(ladder_pass,ZS_BYTE); } //byte s
42507 void FFScript::setComboData_lock_block_type(){ SET_COMBODATA_TYPE_INT(lock_block_type,ZS_BYTE); } //byte t
42508 void FFScript::setComboData_lock_block_change(){ SET_COMBODATA_TYPE_INT(lock_block_change,ZS_LONG); } //int32_t u
42509 void FFScript::setComboData_magic_mirror_type(){ SET_COMBODATA_TYPE_INT(magic_mirror_type,ZS_BYTE); } //byte v
42510 void FFScript::setComboData_modify_hp_amount(){ SET_COMBODATA_TYPE_INT(modify_hp_amount,ZS_SHORT); } //int16_t w
42511 void FFScript::setComboData_modify_hp_delay(){ SET_COMBODATA_TYPE_INT(modify_hp_delay,ZS_BYTE); } //byte x
42512 void FFScript::setComboData_modify_hp_type(){ SET_COMBODATA_TYPE_INT(modify_hp_type,ZS_BYTE); } //byte y
42513 void FFScript::setComboData_modify_mp_amount(){ SET_COMBODATA_TYPE_INT(modify_mp_amount,ZS_SHORT); } //int16_t z
42514 void FFScript::setComboData_modify_mp_delay(){ SET_COMBODATA_TYPE_INT(modify_mp_delay,ZS_BYTE); } //byte aa
42515 void FFScript::setComboData_modify_mp_type(){ SET_COMBODATA_TYPE_INT(modify_mp_type,ZS_BYTE); } //byte ab
42516 void FFScript::setComboData_no_push_blocks(){ SET_COMBODATA_TYPE_INT(no_push_blocks,ZS_BYTE); } //byte ac
42517 void FFScript::setComboData_overhead(){ SET_COMBODATA_TYPE_INT(overhead,ZS_BYTE); } //byte ad
42518 void FFScript::setComboData_place_enemy(){ SET_COMBODATA_TYPE_INT(place_enemy,ZS_BYTE); } //byte ae
42519 void FFScript::setComboData_push_direction(){ SET_COMBODATA_TYPE_INT(push_direction,ZS_BYTE); } //byte af
42520 void FFScript::setComboData_push_weight(){ SET_COMBODATA_TYPE_INT(push_weight,ZS_BYTE); } //byte ag heavy or not
42521 void FFScript::setComboData_push_wait(){ SET_COMBODATA_TYPE_INT(push_wait,ZS_BYTE); } //byte ah
42522 void FFScript::setComboData_pushed(){ SET_COMBODATA_TYPE_INT(pushed,ZS_BYTE); } //byte ai
42523 void FFScript::setComboData_raft(){ SET_COMBODATA_TYPE_INT(raft,ZS_BYTE); } //byte aj
42524 void FFScript::setComboData_reset_room(){ SET_COMBODATA_TYPE_INT(reset_room,ZS_BYTE); } //byte ak
42525 void FFScript::setComboData_save_point_type(){ SET_COMBODATA_TYPE_INT(save_point_type,ZS_BYTE); } //byte al
42526 void FFScript::setComboData_screen_freeze_type(){ SET_COMBODATA_TYPE_INT(screen_freeze_type,ZS_BYTE); } //byte am
42527
42528 void FFScript::setComboData_secret_combo(){ SET_COMBODATA_TYPE_INT(secret_combo,ZS_BYTE); } //byte an
42529 void FFScript::setComboData_singular(){ SET_COMBODATA_TYPE_INT(singular,ZS_BYTE); } //byte ao
42530 void FFScript::setComboData_slow_movement(){ SET_COMBODATA_TYPE_INT(slow_movement,ZS_BYTE); } //byte ap
42531 void FFScript::setComboData_statue_type(){ SET_COMBODATA_TYPE_INT(statue_type,ZS_BYTE); } //byte aq
42532 void FFScript::setComboData_step_type(){ SET_COMBODATA_TYPE_INT(step_type,ZS_BYTE); } //byte ar
42533 void FFScript::setComboData_step_change_to(){ SET_COMBODATA_TYPE_INT(step_change_to,ZS_LONG); } //int32_t as
42534
42535 void FFScript::setComboData_strike_remnants(){ SET_COMBODATA_TYPE_INT(strike_remnants,ZS_LONG); } //int32_t au
42536 void FFScript::setComboData_strike_remnants_type(){ SET_COMBODATA_TYPE_INT(strike_remnants_type,ZS_BYTE); } //byte av
42537 void FFScript::setComboData_strike_change(){ SET_COMBODATA_TYPE_INT(strike_change,ZS_LONG); } //int32_t aw
42538 void FFScript::setComboData_strike_item(){ SET_COMBODATA_TYPE_INT(strike_item,ZS_SHORT); } //int16_t ax
42539 void FFScript::setComboData_touch_item(){ SET_COMBODATA_TYPE_INT(touch_item,ZS_SHORT); } //int16_t ay
42540 void FFScript::setComboData_touch_stairs(){ SET_COMBODATA_TYPE_INT(touch_stairs,ZS_BYTE); } //byte az
42541 void FFScript::setComboData_trigger_type(){ SET_COMBODATA_TYPE_INT(trigger_type,ZS_BYTE); } //byte ba
42542 void FFScript::setComboData_trigger_sensitive(){ SET_COMBODATA_TYPE_INT(trigger_sensitive,ZS_BYTE); } //byte bb
42543 void FFScript::setComboData_warp_type(){ SET_COMBODATA_TYPE_INT(warp_type,ZS_BYTE); } //byte bc
42544 void FFScript::setComboData_warp_sensitive(){ SET_COMBODATA_TYPE_INT(warp_sensitive,ZS_BYTE); } //byte bd
42545 void FFScript::setComboData_warp_direct(){ SET_COMBODATA_TYPE_INT(warp_direct,ZS_BYTE); } //byte be
42546 void FFScript::setComboData_warp_location(){ SET_COMBODATA_TYPE_INT(warp_location,ZS_BYTE); } //byte bf
42547 void FFScript::setComboData_water(){ SET_COMBODATA_TYPE_INT(water,ZS_BYTE); } //byte bg
42548 void FFScript::setComboData_whistle(){ SET_COMBODATA_TYPE_INT(whistle,ZS_BYTE); } //byte bh
42549 void FFScript::setComboData_win_game(){ SET_COMBODATA_TYPE_INT(win_game,ZS_BYTE); } //byte bi
42550 void FFScript::setComboData_block_weapon_lvl(){ SET_COMBODATA_TYPE_INT(block_weapon_lvl,ZS_BYTE); } //byte bj - max level of weapon to block
42551
42552 //combobuf
42553 void FFScript::setComboData_tile(){ SET_COMBODATA_VAR_INT(tile,ZS_WORD); } //newcombo, word
42554 void FFScript::setComboData_flip(){ SET_COMBODATA_VAR_INT(flip,ZS_BYTE); } //newcombo byte
42555
42556 void FFScript::setComboData_walk(){ SET_COMBODATA_VAR_INT(walk,ZS_BYTE); } //newcombo byte
42557 void FFScript::setComboData_type(){ SET_COMBODATA_VAR_INT(type,ZS_BYTE); } //newcombo byte
42558 void FFScript::setComboData_csets(){ SET_COMBODATA_VAR_INT(csets,ZS_BYTE); } //newcombo byte
42559 void FFScript::setComboData_frames(){ SET_COMBODATA_VAR_INT(frames,ZS_BYTE); } //newcombo byte
42560 void FFScript::setComboData_speed(){ SET_COMBODATA_VAR_INT(speed,ZS_BYTE); } //newcombo byte
42561 void FFScript::setComboData_nextcombo(){ SET_COMBODATA_VAR_INT(nextcombo,ZS_WORD); } //newcombo word
42562 void FFScript::setComboData_nextcset(){ SET_COMBODATA_VAR_INT(nextcset,ZS_BYTE); } //newcombo byte
42563 void FFScript::setComboData_flag(){ SET_COMBODATA_VAR_INT(flag,ZS_BYTE); } //newcombo byte
42564 void FFScript::setComboData_skipanim(){ SET_COMBODATA_VAR_INT(skipanim,ZS_BYTE); } //newcombo byte
42565 void FFScript::setComboData_nexttimer(){ SET_COMBODATA_VAR_INT(nexttimer,ZS_WORD); } //newcombo word
42566 void FFScript::setComboData_skipanimy(){ SET_COMBODATA_VAR_INT(skipanimy,ZS_BYTE); } //newcombo byte
42567 void FFScript::setComboData_animflags(){ SET_COMBODATA_VAR_INT(animflags,ZS_BYTE); } //newcombo byte
42568
42569 //three inputs, no returns
42570 void FFScript::setComboData_block_weapon(int32_t v){ SET_COMBODATA_TYPE_INDEX(block_weapon,v,ZS_BYTE,32); } //byte array[32] d (ID of LWeapon)
42571 void FFScript::setComboData_strike_weapons(int32_t v){ SET_COMBODATA_TYPE_INDEX(strike_weapons,v,ZS_BYTE,32); } //byte at, arr[32]
42572 void FFScript::setComboData_expansion(int32_t v){ SET_COMBODATA_VAR_INDEX(expansion,v,ZS_BYTE,6); } //newcombo byte, arr[6]
42573
42574 //SpriteData Macros
42575 #define GET_SPRITEDATA_TYPE_INT(member) \
42576 { \
42577 int32_t ID = vbound((get_register(sarg2) / 10000),0,255);\
42578 set_register(sarg1, wpnsbuf[ID].member * 10000); \
42579 }
42580
42581 #define SET_SPRITEDATA_TYPE_INT(member, bound) \
42582 { \
42583 int32_t ID = get_register(sarg1) / 10000; \
42584 int32_t val = vbound( (get_register(sarg2) / 10000), 0, bound); \
42585 if(ID < 1 || ID > 255) \
42586 set_register(sarg1, -10000); \
42587 else \
42588 wpnsbuf[ID].member = val; \
42589 }
42590
42591 #define SET_SPRITEDATA_TYPE_INT_NOBOUND(member) \
42592 { \
42593 int32_t ID = get_register(sarg1) / 10000; \
42594 int32_t val = get_register(sarg2) / 10000; \
42595 if(ID < 1 || ID > 255) \
42596 set_register(sarg1, -10000); \
42597 else \
42598 wpnsbuf[ID].member = val; \
42599 }
42600
42601
42602 void FFScript::getSpriteDataTile(){GET_SPRITEDATA_TYPE_INT(tile);}
42603 void FFScript::getSpriteDataMisc(){GET_SPRITEDATA_TYPE_INT(misc);}
42604 void FFScript::getSpriteDataCSets(){GET_SPRITEDATA_TYPE_INT(csets);}
42605 void FFScript::getSpriteDataFrames(){GET_SPRITEDATA_TYPE_INT(frames);}
42606 void FFScript::getSpriteDataSpeed(){GET_SPRITEDATA_TYPE_INT(speed);}
42607 void FFScript::getSpriteDataType(){GET_SPRITEDATA_TYPE_INT(type);}
42608 //void FFScript::getSpriteDataString();
42609
42610
42611
42612 void FFScript::setSpriteDataTile(){SET_SPRITEDATA_TYPE_INT(tile,ZS_WORD);}
42613 void FFScript::setSpriteDataMisc(){SET_SPRITEDATA_TYPE_INT(misc,ZS_CHAR);}
42614 void FFScript::setSpriteDataCSets(){SET_SPRITEDATA_TYPE_INT(csets,ZS_CHAR);}
42615 void FFScript::setSpriteDataFrames(){SET_SPRITEDATA_TYPE_INT(frames,ZS_CHAR);}
42616 void FFScript::setSpriteDataSpeed(){SET_SPRITEDATA_TYPE_INT(speed,ZS_CHAR);}
42617 void FFScript::setSpriteDataType(){SET_SPRITEDATA_TYPE_INT(type,ZS_CHAR);}
42618 //void FFScript::setSpriteDataString();
42619
42620
42621 void FFScript::do_setMIDI_volume(int32_t m)
42622 {
42623 master_volume(-1,(vbound(m,0,255)));
42624 }
42625 void FFScript::do_setMusic_volume(int32_t m)
42626 {
42627 emusic_volume = vbound(m,0,255);
42628 }
42629 void FFScript::do_setDIGI_volume(int32_t m)
42630 {
42631 master_volume((vbound(m,0,255)),-1);
42632 }
42633 void FFScript::do_setSFX_volume(int32_t m)
42634 {
42635 sfx_volume = m;
42636 }
42637 void FFScript::do_setSFX_pan(int32_t m)
42638 {
42639 pan_style = vbound(m,0,3);
42640 }
42641 int32_t FFScript::do_getMIDI_volume()
42642 {
42643 return ((int32_t)midi_volume);
42644 }
42645 int32_t FFScript::do_getMusic_volume()
42646 {
42647 return ((int32_t)emusic_volume);
42648 }
42649 int32_t FFScript::do_getDIGI_volume()
42650 {
42651 return ((int32_t)digi_volume);
42652 }
42653 int32_t FFScript::do_getSFX_volume()
42654 {
42655 return ((int32_t)sfx_volume);
42656 }
42657 int32_t FFScript::do_getSFX_pan()
42658 {
42659 return ((int32_t)pan_style);
42660 }
42661
42662
42663 //Change Game Over Screen Values
42664 void FFScript::FFSetSaveScreenSetting()
42665 {
42666
42667 int32_t indx = get_register(sarg1) / 10000;
42668 int32_t value = get_register(sarg2) / 10000; //bounded in zelda.cpp
42669 if(indx < 0 || indx > 11)
42670 set_register(sarg1, -10000);
42671 else
42672 SetSaveScreenSetting(indx, value);
42673 }
42674
42675
42676
42677 void FFScript::FFChangeSubscreenText()
42678 {
42679
42680 int32_t index = get_register(sarg1) / 10000;
42681 int32_t arrayptr = get_register(sarg2) / 10000;
42682
42683 if ( index < 0 || index > 3 )
42684 {
42685 al_trace("The index supplied to Game->SetSubscreenText() is invalid. The index specified was: %d /n", index);
42686 return;
42687 }
42688
42689 string filename_str;
42690
42691
42692
42693 ArrayH::getString(arrayptr, filename_str, 73);
42694 ChangeSubscreenText(index,filename_str.c_str());
42695
42696 //newtext[32]='\0';
42697
42698
42699
42700 }
42701
42702 void FFScript::do_typedpointer_typecast(const bool v)
42703 {
42704 int32_t ptr = SH::get_arg(sarg1, v);
42705 set_register(sarg1, ptr);
42706 }
42707
42708 void FFScript::SetItemMessagePlayed(int32_t itm)
42709 {
42710 game->item_messages_played[itm] = 1;
42711 }
42712 bool FFScript::GetItemMessagePlayed(int32_t itm)
42713 {
42714 return ((game->item_messages_played[itm] ) ? true : false);
42715 }
42716
42717 int32_t FFScript::getQRBit(int32_t rule)
42718 {
42719 return ( get_qr(rule) ? 1 : 0 );
42720 }
42721
42722 12311481 void FFScript::setHeroAction(int32_t a)
42723 {
42724 12311481 FF_hero_action = vbound(a, 0, 255);
42725 12311481 }
42726
42727 52062505 int32_t FFScript::getHeroAction()
42728 {
42729 52062505 int32_t special_action = Hero.getAction2();
42730
2/2
✓ Branch 0 taken 191669 times.
✓ Branch 1 taken 51870836 times.
52062505 if ( special_action != -1 ) return special_action; //spin, dive, charge
42731 51870836 else return FF_hero_action; //everything else
42732 52062505 }
42733 //get_bit
42734
42735 21031146 int32_t FFScript::GetScriptObjectUID(int32_t type)
42736 {
42737 21031146 ++script_UIDs[type];
42738 21031146 return script_UIDs[type];
42739 }
42740
42741 121 void FFScript::SetNegArray()
42742 {
42743 121 can_neg_array = !get_qr(qr_ZS_NO_NEG_ARRAY);
42744 121 }
42745
42746 408 void FFScript::init()
42747 {
42748 408 eventData.clear();
42749 408 countGenScripts();
42750 408 countObjects();
42751
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 408 times.
4488 for ( int32_t q = 0; q < wexLast; q++ ) warpex[q] = 0;
42752 408 print_ZASM = zasm_debugger;
42753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if ( zasm_debugger )
42754 {
42755 ZASMPrint(true);
42756 zasm_break_mode = ZASM_BREAK_HALT;
42757 }
42758
42759 408 temp_no_stepforward = 0;
42760 408 nostepforward = 0;
42761
42762 408 can_neg_array = !get_qr(qr_ZS_NO_NEG_ARRAY);
42763
42764 408 numscriptdraws = 0;
42765 408 skipscriptdraws = false;
42766 408 max_ff_rules = qr_MAX;
42767 408 coreflags = 0;
42768 408 skip_ending_credits = 0;
42769 408 music_update_cond = 0;
42770 408 music_update_flags = 0;
42771 //quest_format : is this properly initialised?
42772
2/2
✓ Branch 0 taken 27744 times.
✓ Branch 1 taken 408 times.
28152 for ( int32_t q = 0; q < susptLAST; q++ ) { system_suspend[q] = 0; }
42773
2/2
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 408 times.
1632 for ( int32_t q = 0; q < UID_TYPES; ++q ) { script_UIDs[q] = 0; }
42774 //for ( int32_t q = 0; q < 512; q++ ) FF_rules[q] = 0;
42775 408 FFCore.zasm_break_mode = ZASM_BREAK_NONE;
42776
42777 408 usr_midi_volume = midi_volume;
42778 408 usr_digi_volume = digi_volume;
42779 408 usr_sfx_volume = sfx_volume;
42780 408 usr_music_volume = emusic_volume;
42781
42782 408 usr_panstyle = pan_style;
42783 408 FF_hero_action = 0;
42784 408 enemy_removal_point[spriteremovalY1] = -32767;
42785 408 enemy_removal_point[spriteremovalY2] = 32767;
42786 408 enemy_removal_point[spriteremovalX1] = -32767;
42787 408 enemy_removal_point[spriteremovalX2] = 32767;
42788 408 enemy_removal_point[spriteremovalZ1] = -32767;
42789 408 enemy_removal_point[spriteremovalZ2] = 32767;
42790
42791 //Clear internal arrays for use by <std>, <ghost>, <tango>
42792
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 408 times.
104856 for ( int32_t q = 0; q < 256; ++q )
42793 {
42794 104448 StdArray[q] = 0;
42795 104448 GhostArray[q] = 0;
42796 104448 TangoArray[q] = 0;
42797 104448 }
42798
42799
2/2
✓ Branch 0 taken 1632 times.
✓ Branch 1 taken 408 times.
2040 for ( int32_t q = 0; q < 4; q++ )
42800 {
42801 1632 FF_screenbounds[q] = 0;
42802 1632 FF_screen_dimensions[q] = 0;
42803 1632 FF_subscreen_dimensions[q] = 0;
42804 1632 FF_eweapon_removal_bounds[q] = 0;
42805 1632 FF_lweapon_removal_bounds[q] = 0;
42806 1632 }
42807
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 408 times.
4488 for ( int32_t q = 0; q < FFSCRIPTCLASS_CLOCKS; q++ )
42808 {
42809 4080 FF_clocks[q] = 0;
42810 4080 }
42811
2/2
✓ Branch 0 taken 8160 times.
✓ Branch 1 taken 408 times.
8568 for ( int32_t q = 0; q < SCRIPT_DRAWING_RULES; q++ )
42812 {
42813 8160 ScriptDrawingRules[q] = 0;
42814 8160 }
42815
2/2
✓ Branch 0 taken 2448 times.
✓ Branch 1 taken 408 times.
2856 for ( int32_t q = 0; q < NUM_USER_MIDI_OVERRIDES; q++ )
42816 {
42817 2448 FF_UserMidis[q] = 0;
42818 2448 }
42819 408 subscreen_scroll_speed = 0; //make a define for a default and read quest override! -Z
42820 408 kb_typing_mode = false;
42821 408 initIncludePaths();
42822 408 initRunString();
42823 //clearRunningItemScripts();
42824 408 tempScreens[0] = tmpscr;
42825 408 ScrollingScreens[0] = tmpscr+1;
42826
2/2
✓ Branch 0 taken 2448 times.
✓ Branch 1 taken 408 times.
2856 for(int32_t q = 0; q < 6; ++q)
42827 {
42828 2448 tempScreens[q+1] = tmpscr2+q;
42829 2448 ScrollingScreens[q+1] = tmpscr3+q;
42830 2448 }
42831 408 ScrollingData[SCROLLDATA_DIR] = -1;
42832 408 ScrollingData[SCROLLDATA_NX] = 0;
42833 408 ScrollingData[SCROLLDATA_NY] = 0;
42834 408 ScrollingData[SCROLLDATA_OX] = 0;
42835 408 ScrollingData[SCROLLDATA_OY] = 0;
42836 408 user_rng_init();
42837 408 clear_script_engine_data();
42838
2/2
✓ Branch 0 taken 10178 times.
✓ Branch 1 taken 408 times.
10586 for (auto &it : jitted_scripts)
42839 {
42840 10178 jit_delete_script_handle(it.second);
42841 }
42842 408 jitted_scripts.clear();
42843 408 seen_scripts.clear();
42844 408 script_debug_handles.clear();
42845 408 runtime_script_debug_handle = nullptr;
42846 408 }
42847
42848 void FFScript::shutdown()
42849 {
42850 for (auto &it : jitted_scripts)
42851 {
42852 jit_delete_script_handle(it.second);
42853 }
42854 jitted_scripts.clear();
42855 }
42856
42857
42858 void FFScript::SetFFEngineFlag(int32_t flag, bool state)
42859 {
42860 if ( state ) { coreflags |= flag; }
42861 else coreflags &= ~flag;
42862 }
42863
42864 void FFScript::setSubscreenScrollSpeed(byte n)
42865 {
42866 subscreen_scroll_speed = n;
42867 }
42868
42869 int32_t FFScript::getSubscreenScrollSpeed()
42870 {
42871 return (int32_t)subscreen_scroll_speed;
42872 }
42873
42874 void FFScript::do_greyscale(const bool v)
42875 {
42876 bool on = (SH::get_arg(sarg1, v)) != 0;
42877 setMonochrome(on);
42878 }
42879
42880 void FFScript::do_monochromatic(const bool v)
42881 {
42882 int32_t colour = SH::get_arg(sarg1, v)/10000;
42883 setMonochromatic(colour);
42884 }
42885
42886 void FFScript::gfxmonohue()
42887 {
42888 int32_t _r = SH::read_stack(ri->sp + 3) / 10000;
42889 int32_t _g = SH::read_stack(ri->sp + 2) / 10000;
42890 int32_t _b = SH::read_stack(ri->sp + 1) / 10000;
42891 bool m = (SH::read_stack(ri->sp + 0) / 10000);
42892 doGFXMonohue(_r,_g,_b,m);
42893 }
42894
42895 void FFScript::clearTint()
42896 {
42897 doClearTint();
42898 }
42899
42900 void FFScript::Tint()
42901 {
42902 int32_t _r = SH::read_stack(ri->sp + 2) / 10000;
42903 int32_t _g = SH::read_stack(ri->sp + 1) / 10000;
42904 int32_t _b = SH::read_stack(ri->sp + 0) / 10000;
42905 doTint(_r,_g,_b);
42906 }
42907
42908 void FFScript::do_fx_zap(const bool v)
42909 {
42910 int32_t out = SH::get_arg(sarg1, v);
42911
42912 if ( out ) { FFScript::do_zapout(); }
42913 else FFScript::do_zapin();
42914 }
42915
42916 void FFScript::do_fx_wavy(const bool v)
42917 {
42918 int32_t out = SH::get_arg(sarg1, v);
42919
42920 if ( out ) { FFScript::do_wavyout(); }
42921 else FFScript::do_wavyin();
42922 }
42923
42924 225024989 int32_t FFScript::getQuestHeaderInfo(int32_t type)
42925 {
42926 225024989 return quest_format[type];
42927 }
42928
42929 string get_filestr(const bool relative) //Used for 'FileSystem' functions.
42930 {
42931 int32_t strptr = get_register(sarg1)/10000;
42932 string the_string;
42933 ArrayH::getString(strptr, the_string, 512);
42934 the_string = the_string.substr(the_string.find_first_not_of('/'),string::npos); //Kill leading '/'
42935 size_t last = the_string.find_last_not_of('/');
42936 if(last!=string::npos)++last;
42937 the_string = the_string.substr(0,last); //Kill trailing '/'
42938 if(relative)
42939 {
42940 char buf[2048+1] = {0};
42941 if(FFCore.get_scriptfile_path(buf, the_string.c_str()))
42942 the_string = buf;
42943 }
42944 return the_string;
42945 }
42946
42947 void FFScript::do_checkdir(const bool is_dir)
42948 {
42949 string the_string = get_filestr(get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE));
42950 set_register(sarg1, checkPath(the_string.c_str(), is_dir) ? 10000 : 0);
42951 }
42952
42953 void FFScript::do_fs_remove()
42954 {
42955 string the_string = get_filestr(true);
42956 set_register(sarg1, remove(the_string.c_str()) ? 0 : 10000);
42957 }
42958
42959 16 void FFScript::Play_Level_Music()
42960 {
42961 16 int32_t m=tmpscr->screen_midi;
42962
42963
1/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 switch(m)
42964 {
42965 case -2:
42966 music_stop();
42967 break;
42968
42969 case -1:
42970 16 play_DmapMusic();
42971 16 break;
42972
42973 case 1:
42974 jukebox(ZC_MIDI_OVERWORLD);
42975 break;
42976
42977 case 2:
42978 jukebox(ZC_MIDI_DUNGEON);
42979 break;
42980
42981 case 3:
42982 jukebox(ZC_MIDI_LEVEL9);
42983 break;
42984
42985 default:
42986 if(m>=4 && m<4+MAXCUSTOMMIDIS)
42987 jukebox(m+MIDIOFFSET_MAPSCR);
42988 else
42989 music_stop();
42990 }
42991 16 }
42992
42993 16 void FFScript::do_warp_ex(bool v)
42994 {
42995 16 int32_t zscript_array_ptr = SH::get_arg(sarg1, v) / 10000;
42996 16 ArrayManager am(zscript_array_ptr);
42997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(am.invalid()) return;
42998 16 int32_t zscript_array_size = am.size();
42999
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 switch(zscript_array_size)
43000 {
43001 case 8:
43002 // {int32_t type, int32_t dmap, int32_t screen, int32_t x, int32_t y, int32_t effect, int32_t sound, int32_t flags}
43003 {
43004 if(DEVLOGGING) zprint("FFscript.cpp running do_warp_ex with %d args\n", 8);
43005 16 int32_t tmpwarp[8]={0};
43006
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 16 times.
144 for ( int32_t q = 0; q < wexDir; q++ )
43007 {
43008 128 tmpwarp[q] = (am.get(q)/10000);
43009 128 }
43010
43011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)tmpwarp[1]) >= MAXDMAPS )
43012 {
43013 Z_scripterrlog("Invalid DMap ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[1]);
43014 return;
43015 }
43016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)tmpwarp[2]) >= MAPSCRS )
43017 {
43018 Z_scripterrlog("Invalid Screen ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[2]);
43019 return;
43020 }
43021 //Extra sanity guard.
43022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( DMaps[tmpwarp[1]].map*MAPSCRS+DMaps[tmpwarp[1]].xoff+tmpwarp[2] >= (int32_t)TheMaps.size() )
43023 {
43024 Z_scripterrlog("Invalid destination passed to WarpEx(). Aborting.\n");
43025 return;
43026 }
43027 //If we passed the sanity checks, populate the FFCore array and begin the action!
43028
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 16 times.
144 for ( int32_t q = 0; q < wexDir; q++ )
43029 {
43030 128 FFCore.warpex[q] = tmpwarp[q];
43031 128 }
43032 16 FFCore.warpex[wexActive] = 1;
43033 16 FFCore.warpex[wexDir] = -1;
43034
43035 16 break;
43036 }
43037 case 9:
43038 // {int32_t type, int32_t dmap, int32_t screen, int32_t x, int32_t y, int32_t effect, int32_t sound, int32_t flags, int32_t dir}
43039 {
43040 if(DEVLOGGING) zprint("FFscript.cpp running do_warp_ex with %d args\n", 9);
43041 int32_t tmpwarp[9]={0};
43042
43043 for ( int32_t q = 0; q < wexActive; q++ )
43044 {
43045 tmpwarp[q] = (am.get(q)/10000);
43046 }
43047
43048 if ( ((unsigned)tmpwarp[1]) >= MAXDMAPS )
43049 {
43050 Z_scripterrlog("Invalid DMap ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[1]);
43051 return;
43052 }
43053 if ( ((unsigned)tmpwarp[2]) >= MAPSCRS )
43054 {
43055 Z_scripterrlog("Invalid Screen ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[2]);
43056 return;
43057 }
43058 //Extra sanity guard.
43059 if ( DMaps[tmpwarp[1]].map*MAPSCRS+DMaps[tmpwarp[1]].xoff+tmpwarp[2] >= (int32_t)TheMaps.size() )
43060 {
43061 Z_scripterrlog("Invalid destination passed to WarpEx(). Aborting.\n");
43062 return;
43063 }
43064 //If we passed the sanity checks, populate the FFCore array and begin the action!
43065 for ( int32_t q = 0; q < wexActive; q++ )
43066 {
43067 FFCore.warpex[q] = tmpwarp[q];
43068 }
43069 FFCore.warpex[wexActive] = 1;
43070
43071 for ( int32_t q = 0; q < wexActive; q++ )
43072 {
43073 FFCore.warpex[q] = tmpwarp[q];
43074 }
43075
43076 //for ( int32_t q = 0; q < wexLast; q++ )
43077 //{
43078 // zprint("FFCore.warpex[%d] is: %d\n", q, FFCore.warpex[q]);
43079 //}
43080
43081 break;
43082
43083 }
43084
43085 default:
43086 {
43087 Z_scripterrlog("Array supplied to Player->WarpEx() is the wrong size!\n The array size was: &d, and valid sizes are [8] and [9].\n",zscript_array_size);
43088 break;
43089 }
43090
43091
43092
43093 }
43094 16 }
43095
43096 ///////////////////////////////
43097 //* SCRIPT ENGINE FUNCTIONS *//
43098 ////////////////////////////////////////////////////////////////////////////
43099
43100 void FFScript::clearRunningItemScripts()
43101 {
43102 //for ( byte q = 0; q < 256; q++ ) runningItemScripts[q] = 0;
43103 }
43104
43105
43106 4996 void FFScript::warpScriptCheck()
43107 {
43108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4996 times.
4996 if(get_qr(qr_SCRIPTDRAWSINWARPS))
43109 {
43110 FFCore.runWarpScripts(false);
43111 FFCore.runWarpScripts(true); //Waitdraw
43112 }
43113
3/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 4908 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
4996 else if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN) && doscript(ScriptType::ScriptedPassiveSubscreen))
43114 {
43115
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(DMaps[currdmap].passive_sub_script != 0)
43116 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
43117
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
88 if (waitdraw(ScriptType::ScriptedPassiveSubscreen) && DMaps[currdmap].passive_sub_script != 0 && doscript(ScriptType::ScriptedPassiveSubscreen))
43118 {
43119 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
43120 waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
43121 }
43122 88 }
43123 4996 }
43124
43125 void FFScript::runWarpScripts(bool waitdraw)
43126 {
43127 if(waitdraw)
43128 {
43129 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
43130 {
43131 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
43132 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
43133 }
43134 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
43135 {
43136 FFCore.itemScriptEngineOnWaitdraw();
43137 }
43138 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43139 {
43140 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
43141 FFCore.waitdraw(ScriptType::Player) = false;
43142 }
43143 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43144 {
43145 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
43146 FFCore.waitdraw(ScriptType::DMap) = false;
43147 }
43148 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43149 {
43150 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
43151 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
43152 }
43153 //no doscript check here, becauseb of preload? Do we want to write doscript here? -Z 13th July, 2019
43154 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && FFCore.waitdraw(ScriptType::Screen) && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43155 {
43156 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
43157 FFCore.waitdraw(ScriptType::Screen) = 0;
43158 }
43159 }
43160 else
43161 {
43162 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.doscript(ScriptType::Global, GLOBAL_SCRIPT_GAME))
43163 {
43164 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
43165 }
43166 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
43167 {
43168 FFCore.itemScriptEngine();
43169 }
43170 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && doscript(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
43171 {
43172 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
43173 }
43174 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && doscript(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43175 {
43176 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
43177 }
43178 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43179 {
43180 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
43181 }
43182 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43183 {
43184 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
43185 }
43186 }
43187 }
43188
43189 17425627 void FFScript::runF6Engine()
43190 {
43191
5/6
✓ Branch 0 taken 17424942 times.
✓ Branch 1 taken 685 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 17424928 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
17425627 if(!Quit && (GameFlags&GAMEFLAG_TRYQUIT) && !(GameFlags&GAMEFLAG_F6SCRIPT_ACTIVE))
43192 {
43193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(globalscripts[GLOBAL_SCRIPT_F6]->valid())
43194 {
43195 //Incase this was called mid-another script, store ref data
43196 push_ri();
43197 //
43198 clear_bitmap(f6_menu_buf);
43199 blit(framebuf, f6_menu_buf, 0, 0, 0, 0, 256, 224);
43200 initZScriptGlobalScript(GLOBAL_SCRIPT_F6);
43201 int32_t openingwipe = black_opening_count;
43202 int32_t openingshape = black_opening_shape;
43203 black_opening_count = 0; //No opening wipe during F6 menu
43204 if(black_opening_shape==bosFADEBLACK) black_fade(0);
43205 GameFlags |= GAMEFLAG_F6SCRIPT_ACTIVE;
43206 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
43207 pause_all_sfx();
43208
43209 auto& data = get_script_engine_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
43210 while (data.doscript)
43211 {
43212 script_drawing_commands.Clear();
43213 load_control_state();
43214 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_F6, GLOBAL_SCRIPT_F6);
43215 if (data.waitdraw)
43216 {
43217 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_F6, GLOBAL_SCRIPT_F6);
43218 data.waitdraw = false;
43219 }
43220 //Draw
43221 clear_bitmap(framebuf);
43222 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
43223 doScriptMenuDraws();
43224 //
43225 advanceframe(true,true,false);
43226 if(Quit) break; //Something quit, end script running
43227 }
43228 resume_all_sfx();
43229 script_drawing_commands.Clear();
43230 //script_drawing_commands.push_commands(tmpDrawCommands);
43231 GameFlags &= ~GAMEFLAG_F6SCRIPT_ACTIVE;
43232 //Restore opening wipe
43233 black_opening_count = openingwipe;
43234 black_opening_shape = openingshape;
43235 if(openingshape == bosFADEBLACK)
43236 {
43237 refreshTints();
43238 memcpy(tempblackpal, RAMpal, PAL_SIZE*sizeof(RGB));
43239 }
43240 //Restore script refinfo
43241 pop_ri();
43242 //
43243 if(!Quit)
43244 {
43245 if(!get_qr(qr_NOCONTINUE))
43246 f_Quit(qQUIT);
43247 }
43248 }
43249 14 else f_Quit(qQUIT);
43250 14 zc_readkey(KEY_F6);
43251 14 GameFlags &= ~GAMEFLAG_TRYQUIT;
43252 14 }
43253 17425627 }
43254 void FFScript::runOnDeathEngine()
43255 {
43256 if(!playerscripts[SCRIPT_PLAYER_DEATH]->valid()) return; //No script to run
43257 clear_bitmap(script_menu_buf);
43258 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
43259 initZScriptHeroScripts();
43260 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
43261 kill_sfx(); //No need to pause/resume; the player is dead.
43262 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
43263
43264 auto& data = get_script_engine_data(ScriptType::Player);
43265 while (data.doscript && !Quit)
43266 {
43267 script_drawing_commands.Clear();
43268 load_control_state();
43269 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_DEATH);
43270 if (data.waitdraw)
43271 {
43272 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_DEATH);
43273 data.waitdraw = false;
43274 }
43275 //Draw
43276 clear_bitmap(framebuf);
43277 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
43278 doScriptMenuDraws();
43279 //
43280 advanceframe(true);
43281 }
43282 script_drawing_commands.Clear();
43283 //script_drawing_commands.push_commands(tmpDrawCommands);
43284 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
43285 }
43286 121 void FFScript::runOnLaunchEngine()
43287 {
43288
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 1 times.
121 if(!globalscripts[GLOBAL_SCRIPT_ONLAUNCH]->valid()) return; //No script to run
43289 //Do NOT blit the prior screen to this bitmap; that would be the TITLE SCREEN.
43290 1 clear_to_color(script_menu_buf,BLACK);
43291 1 initZScriptGlobalScript(GLOBAL_SCRIPT_ONLAUNCH);
43292 1 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
43293 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
43294
43295 1 auto& data = get_script_engine_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
43296
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
2 while (data.doscript && !Quit)
43297 {
43298 1 script_drawing_commands.Clear();
43299 1 load_control_state();
43300 1 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH, GLOBAL_SCRIPT_ONLAUNCH);
43301
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (data.waitdraw)
43302 {
43303 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH, GLOBAL_SCRIPT_ONLAUNCH);
43304 data.waitdraw = false;
43305 }
43306 //Draw
43307 1 clear_bitmap(framebuf);
43308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
43309
43310 1 doScriptMenuDraws();
43311 //
43312 1 advanceframe(true);
43313 }
43314 1 script_drawing_commands.Clear();
43315 //script_drawing_commands.push_commands(tmpDrawCommands);
43316 1 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
43317 121 }
43318 10 bool FFScript::runGenericFrozenEngine(const word script, const int32_t *init_data)
43319 {
43320 static int32_t local_i = 0;
43321
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(script < 1 || script >= NUMSCRIPTSGENERIC) return false;
43322
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(init_data)
43323 {
43324 for(int q = 0; q < 8; ++q)
43325 {
43326 user_scripts[script].initd[q] = init_data[q];
43327 }
43328 }
43329
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!genericscripts[script]->valid()) return false; //No script to run
43330 //Store script refinfo
43331 10 push_ri();
43332 refInfo local_ri;
43333 int32_t local_stack[MAX_SCRIPT_REGISTERS];
43334 10 local_ri.Clear();
43335 10 memset(local_stack, 0, sizeof(local_stack));
43336 10 genericActiveData.push_back(&local_ri);
43337 10 generic_active_stack.push_back(&local_stack);
43338 10 bool tmp_init = gen_active_initialized;
43339 10 bool tmp_doscript = gen_active_doscript;
43340 10 gen_active_doscript = true;
43341 10 gen_active_initialized = false;
43342 //run script
43343 10 uint32_t fl = GameFlags & GAMEFLAG_SCRIPTMENU_ACTIVE;
43344 10 BITMAP* tmpbuf = script_menu_buf;
43345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(fl)
43346 {
43347 script_menu_buf = create_bitmap_ex(8,256,224);
43348 }
43349 10 clear_bitmap(script_menu_buf);
43350 10 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
43351 10 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
43352 10 ++local_i;
43353 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
43354
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1542 times.
✓ Branch 2 taken 1542 times.
✓ Branch 3 taken 10 times.
1552 while(gen_active_doscript && !Quit)
43355 {
43356 1542 script_drawing_commands.Clear();
43357 1542 load_control_state();
43358 1542 ZScriptVersion::RunScript(ScriptType::GenericFrozen, script, local_i);
43359 //Draw
43360 1542 clear_bitmap(framebuf);
43361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1542 times.
1542 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
43362 1542 doScriptMenuDraws();
43363 //
43364 1542 advanceframe(true);
43365 }
43366 10 script_drawing_commands.Clear();
43367 //script_drawing_commands.push_commands(tmpDrawCommands);
43368 10 --local_i;
43369 10 gen_active_doscript = tmp_doscript;
43370 10 gen_active_initialized = tmp_init;
43371 //clear
43372 10 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
43373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(fl)
43374 {
43375 GameFlags |= fl;
43376 destroy_bitmap(script_menu_buf);
43377 script_menu_buf = tmpbuf;
43378 }
43379 10 genericActiveData.pop_back();
43380 10 generic_active_stack.pop_back();
43381 //Restore script refinfo
43382 10 pop_ri();
43383 10 return true;
43384 10 }
43385
43386 794 bool FFScript::runScriptedActiveSusbcreen()
43387 {
43388 794 word activesubscript = DMaps[currdmap].active_sub_script;
43389
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 754 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
794 if(!activesubscript || !dmapscripts[activesubscript]->valid()) return false; //No script to run
43390 40 word passivesubscript = DMaps[currdmap].passive_sub_script;
43391 40 word dmapactivescript = DMaps[currdmap].script;
43392 40 clear_bitmap(script_menu_buf);
43393 40 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
43394 40 initZScriptScriptedActiveSubscreen();
43395 40 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
43396 40 word script_dmap = currdmap;
43397 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
43398 40 pause_all_sfx();
43399 40 auto& data = get_script_engine_data(ScriptType::ScriptedActiveSubscreen);
43400
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 6632 times.
✓ Branch 2 taken 6632 times.
✓ Branch 3 taken 40 times.
6672 while (data.doscript && !Quit)
43401 {
43402 6632 script_drawing_commands.Clear();
43403 6632 load_control_state();
43404
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6632 if(get_qr(qr_DMAP_ACTIVE_RUNS_DURING_ACTIVE_SUBSCRIPT) && DMaps[script_dmap].script != 0 && doscript(ScriptType::DMap))
43405 {
43406 ZScriptVersion::RunScript(ScriptType::DMap, dmapactivescript, script_dmap);
43407 }
43408
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6632 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_DURING_ACTIVE_SUBSCRIPT)!=0 && DMaps[script_dmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen))
43409 {
43410 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, passivesubscript, script_dmap);
43411 }
43412 6632 ZScriptVersion::RunScript(ScriptType::ScriptedActiveSubscreen, activesubscript, script_dmap);
43413
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6632 if(waitdraw(ScriptType::DMap) && (get_qr(qr_DMAP_ACTIVE_RUNS_DURING_ACTIVE_SUBSCRIPT) && DMaps[script_dmap].script != 0 && doscript(ScriptType::DMap)))
43414 {
43415 ZScriptVersion::RunScript(ScriptType::DMap, dmapactivescript, script_dmap);
43416 waitdraw(ScriptType::DMap) = false;
43417 }
43418
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6632 if(waitdraw(ScriptType::ScriptedPassiveSubscreen) && (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_DURING_ACTIVE_SUBSCRIPT)!=0 && DMaps[script_dmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen)))
43419 {
43420 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, passivesubscript, script_dmap);
43421 waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
43422 }
43423
3/4
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1160 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5472 times.
6632 if (data.waitdraw && data.doscript)
43424 {
43425 5472 ZScriptVersion::RunScript(ScriptType::ScriptedActiveSubscreen, activesubscript, script_dmap);
43426 5472 data.waitdraw = false;
43427 5472 }
43428 //Draw
43429 6632 clear_bitmap(framebuf);
43430
2/4
✓ Branch 0 taken 6632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6632 times.
6632 if(currdmap == script_dmap && ( !FFCore.system_suspend[susptCOMBOANIM] ) ) animate_combos();
43431 6632 doScriptMenuDraws();
43432 //
43433 6632 advanceframe(true);
43434 //Handle warps; run game_loop once!
43435
1/2
✓ Branch 0 taken 6632 times.
✗ Branch 1 not taken.
6632 if(currdmap != script_dmap)
43436 {
43437 activesubscript = DMaps[currdmap].active_sub_script;
43438 if(!activesubscript || !dmapscripts[activesubscript]->valid()) return true; //No script to run
43439 passivesubscript = DMaps[currdmap].passive_sub_script;
43440 dmapactivescript = DMaps[currdmap].script;
43441 script_dmap = currdmap;
43442 //Reset the background image
43443 game_loop();
43444 clear_bitmap(script_menu_buf);
43445 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
43446 //Now loop without advancing frame, so that the subscreen script can draw immediately.
43447 }
43448 }
43449 40 resume_all_sfx();
43450 40 script_drawing_commands.Clear();
43451 //script_drawing_commands.push_commands(tmpDrawCommands);
43452 40 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
43453 40 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
43454 40 return true;
43455 794 }
43456 417 bool FFScript::runOnMapScriptEngine()
43457 {
43458 417 word onmap_script = DMaps[currdmap].onmap_script;
43459
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 417 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
417 if(!onmap_script || !dmapscripts[onmap_script]->valid()) return false; //No script to run
43460 clear_bitmap(script_menu_buf);
43461 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
43462 initZScriptOnMapScript();
43463 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
43464 word script_dmap = currdmap;
43465 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
43466 pause_all_sfx();
43467
43468 auto& data = get_script_engine_data(ScriptType::OnMap);
43469 while (data.doscript && !Quit)
43470 {
43471 script_drawing_commands.Clear();
43472 load_control_state();
43473 ZScriptVersion::RunScript(ScriptType::OnMap, onmap_script, script_dmap);
43474 if (data.waitdraw && data.doscript)
43475 {
43476 ZScriptVersion::RunScript(ScriptType::OnMap, onmap_script, script_dmap);
43477 data.waitdraw = false;
43478 }
43479 //Draw
43480 clear_bitmap(framebuf);
43481 if(currdmap == script_dmap && ( !FFCore.system_suspend[susptCOMBOANIM] ) ) animate_combos();
43482 doScriptMenuDraws();
43483 //
43484 advanceframe(true);
43485 //Handle warps; run game_loop once!
43486 if(currdmap != script_dmap)
43487 {
43488 onmap_script = DMaps[currdmap].onmap_script;
43489 if(!onmap_script || !dmapscripts[onmap_script]->valid()) return true; //No script to run
43490 script_dmap = currdmap;
43491 //Reset the background image
43492 game_loop();
43493 clear_bitmap(script_menu_buf);
43494 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
43495 //Now loop without advancing frame, so that the subscreen script can draw immediately.
43496 }
43497 }
43498 resume_all_sfx();
43499 script_drawing_commands.Clear();
43500 //script_drawing_commands.push_commands(tmpDrawCommands);
43501 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
43502 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
43503 return true;
43504 417 }
43505
43506 8175 void FFScript::doScriptMenuDraws()
43507 {
43508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8175 times.
8175 BITMAP* menu_buf = ((GameFlags & GAMEFLAG_F6SCRIPT_ACTIVE) != 0) ? f6_menu_buf : script_menu_buf;
43509 8175 blit(menu_buf, framebuf, 0, 0, 0, 0, 256, 224);
43510 //Script draws
43511 8175 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
43512 8175 }
43513
43514 102 void FFScript::runOnSaveEngine()
43515 {
43516
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(globalscripts[GLOBAL_SCRIPT_ONSAVE]->valid())
43517 {
43518 push_ri();
43519 //Prevent getting here via Quit from causing a forced-script-quit after 1000 commands!
43520 int32_t tQuit = Quit;
43521 Quit = 0;
43522 //
43523 initZScriptGlobalScript(GLOBAL_SCRIPT_ONSAVE);
43524 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE, GLOBAL_SCRIPT_ONSAVE);
43525 //
43526 pop_ri();
43527 Quit = tQuit;
43528 }
43529 102 }
43530
43531 8068310 bool FFScript::itemScriptEngine()
43532 {
43533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8068310 times.
8068310 if ( FFCore.system_suspend[susptITEMSCRIPTENGINE] ) return false;
43534 //zprint("Trying to check if an %s is running.\n","item script");
43535
2/2
✓ Branch 0 taken 2065487360 times.
✓ Branch 1 taken 8068310 times.
2073555670 for ( int32_t q = 0; q < MAXITEMS; q++ )
43536 {
43537
43538 //zprint("Checking item ID: %d\n",q);
43539
3/4
✓ Branch 0 taken 18893643 times.
✓ Branch 1 taken 2046593717 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18893643 times.
2065487360 if ( itemsbuf[q].script <= 0 || itemsbuf[q].script > NUMSCRIPTITEM ) continue; // > NUMSCRIPTITEM as someone could force an invaid script slot!
43540
43541 18893643 auto& data = get_script_engine_data(ScriptType::Item, q);
43542
2/2
✓ Branch 0 taken 3306 times.
✓ Branch 1 taken 18890337 times.
18893643 if ( data.doscript < 1 ) continue;
43543
43544 //Passive items
43545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3306 times.
3306 if (((itemsbuf[q].flags&ITEM_PASSIVESCRIPT)))
43546 {
43547 if(game->item[q] && (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
43548 {
43549 if(get_qr(qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
43550 && current_item(itemsbuf[q].family) > itemsbuf[q].fam_type)
43551 data.doscript = 0;
43552 else ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
43553 if(!data.doscript) //Item script ended. Clear the data, if any remains.
43554 {
43555 data.ref.Clear();
43556 data.initialized = false;
43557 data.waitdraw = false;
43558 FFScript::deallocateAllScriptOwned(ScriptType::Item, q);
43559 }
43560 }
43561 }
43562 else
43563 {
43564
43565 //Normal Items
43566 //zprint("Running ItemScriptEngine() for item ID: %dn", q);
43567 /*! What happens here: When an item script is first run by the user using that utem, the script runs for one frame.
43568 After executing RunScript(), item_doscript is set to '1' in hero.cpp.
43569 If the quest allows the item to continue running, the itemScriptEngine() function ignores running the
43570 same item script (again) that frame, and insteads increments item_doscript to '2'.
43571 If item_doscript == 2, then we know we are on the second frame, and we run it perpetually.
43572 If the QR to enable item scripts to run for more than one frame is not enabled, then item_doscript is set to '0'.
43573 If the item flag 'PERPETUAL SCRIPT' is enabled, then we ignore the lack of item_doscript==2.
43574 This allows passive item scripts to function.
43575 */
43576
43577 3306 auto& data = get_script_engine_data(ScriptType::Item, q);
43578
43579
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3293 times.
3306 if ( data.doscript == 1 ) // FIrst frame, normally set in hero.cpp
43580 {
43581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if ( get_qr(qr_ITEMSCRIPTSKEEPRUNNING) )
43582 {
43583 13 data.doscript = 2;
43584 13 }
43585 13 }
43586
1/2
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
3293 else if (data.doscript == 2) //Second frame and later, if scripts continue to run.
43587 {
43588 3293 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
43589 3293 }
43590 else if (data.doscript == 3) //Run via itemdata->RunScript
43591 {
43592 if ( (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
43593 {
43594 data.doscript = 2; //Reduce to normal run status
43595 }
43596 else
43597 {
43598 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q & 0xFFF);
43599 data.doscript = 0;
43600 }
43601 }
43602 else if(data.doscript==4) //Item set itself false, kill script and clear data here
43603 {
43604 data.doscript = 0;
43605 }
43606
2/2
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 28 times.
3306 if(data.doscript==0) //Item script ended. Clear the data, if any remains.
43607 {
43608 28 data.ref.Clear();
43609 28 data.initialized = false;
43610 28 data.waitdraw = false;
43611 28 FFScript::deallocateAllScriptOwned(ScriptType::Item, q);
43612 28 }
43613 }
43614 3306 }
43615 8068310 return false;
43616 8068310 }
43617
43618 8155275 bool FFScript::itemScriptEngineOnWaitdraw()
43619 {
43620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8155275 times.
8155275 if ( FFCore.system_suspend[susptITEMSCRIPTENGINE] ) return false;
43621 //zprint("Trying to check if an %s is running.\n","item script");
43622
2/2
✓ Branch 0 taken 2087750400 times.
✓ Branch 1 taken 8155275 times.
2095905675 for ( int32_t q = 0; q < MAXITEMS; q++ )
43623 {
43624 //zprint("Checking item ID: %d\n",q);
43625
3/4
✓ Branch 0 taken 19396249 times.
✓ Branch 1 taken 2068354151 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19396249 times.
2087750400 if ( itemsbuf[q].script <= 0 || itemsbuf[q].script > NUMSCRIPTITEM ) continue; // > NUMSCRIPTITEM as someone could force an invaid script slot!
43626
43627 19396249 auto& data = get_script_engine_data(ScriptType::Item, q);
43628
43629
2/2
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 19392971 times.
19396249 if ( data.doscript < 1 ) continue;
43630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
3278 if (!data.waitdraw) continue;
43631 else data.waitdraw = false;
43632
43633 //zprint("Running ItemScriptEngine() for item ID: %dn", q);
43634 /*! What happens here: When an item script is first run by the user using that utem, the script runs for one frame.
43635 After executing RunScript(), item_doscript is set to '1' in hero.cpp.
43636 If the quest allows the item to continue running, the itemScriptEngine() function ignores running the
43637 same item script (again) that frame, and insteads increments item_doscript to '2'.
43638 If item_doscript == 2, then we know we are on the second frame, and we run it perpetually.
43639 If the QR to enable item scripts to run for more than one frame is not enabled, then item_doscript is set to '0'.
43640 If the item flag 'PERPETUAL SCRIPT' is enabled, then we ignore the lack of item_doscript==2.
43641 This allows passive item scripts to function.
43642 */
43643 //Passive items
43644 if ((itemsbuf[q].flags&ITEM_PASSIVESCRIPT))
43645 {
43646 if(game->item[q] && (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
43647 {
43648 if(get_qr(qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
43649 && current_item(itemsbuf[q].family) > itemsbuf[q].fam_type)
43650 data.doscript = 0;
43651 else ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
43652 if(!data.doscript) //Item script ended. Clear the data, if any remains.
43653 {
43654 data.ref.Clear();
43655 data.initialized = false;
43656 data.waitdraw = false;
43657 FFScript::deallocateAllScriptOwned(ScriptType::Item, q);
43658 }
43659 }
43660 }
43661 else
43662 {
43663 //Normal items
43664 if ( data.doscript == 1 ) // FIrst frame, normally set in hero.cpp
43665 {
43666 if ( get_qr(qr_ITEMSCRIPTSKEEPRUNNING) )
43667 {
43668 data.doscript = 2;
43669 }
43670 else data.doscript = 0;
43671 }
43672 else if (data.doscript == 2) //Second frame and later, if scripts continue to run.
43673 {
43674 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
43675 }
43676 else if (data.doscript == 3) //Run via itemdata->RunScript
43677 {
43678 if ( (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
43679 {
43680 data.doscript = 2; //Reduce to normal run status
43681 }
43682 else
43683 {
43684 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q & 0xFFF);
43685 data.doscript = 0;
43686 }
43687 }
43688 else if(data.doscript==4) //Item set itself false, kill script and clear data here.
43689 {
43690 data.doscript = 0;
43691 }
43692 if(!data.doscript) //Item script ended. Clear the data, if any remains.
43693 {
43694 data.ref.Clear();
43695 data.initialized = false;
43696 data.waitdraw = false;
43697 FFScript::deallocateAllScriptOwned(ScriptType::Item, q);
43698 }
43699 }
43700 }
43701 8155275 return false;
43702 8155275 }
43703 7337004 void FFScript::npcScriptEngineOnWaitdraw()
43704 {
43705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7337004 times.
7337004 if ( FFCore.system_suspend[susptNPCSCRIPTS] ) return;
43706 7337004 guys.run_script(MODE_WAITDRAW);
43707 7337004 }
43708
43709 7262734 void FFScript::eweaponScriptEngine()
43710 {
43711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7262734 times.
7262734 if ( FFCore.system_suspend[susptEWEAPONSCRIPTS] ) return;
43712 7262734 Ewpns.run_script(MODE_NORMAL);
43713 7262734 }
43714
43715 7337004 void FFScript::lweaponScriptEngineOnWaitdraw()
43716 {
43717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7337004 times.
7337004 if ( FFCore.system_suspend[susptLWEAPONSCRIPTS] ) return;
43718 7337004 Lwpns.run_script(MODE_WAITDRAW);
43719 7337004 }
43720
43721 7349889 void FFScript::eweaponScriptEngineOnWaitdraw()
43722 {
43723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7349889 times.
7349889 if ( FFCore.system_suspend[susptEWEAPONSCRIPTS] ) return;
43724 7349889 Ewpns.run_script(MODE_WAITDRAW);
43725 7349889 }
43726
43727 7262734 void FFScript::itemSpriteScriptEngine()
43728 {
43729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7262734 times.
7262734 if ( FFCore.system_suspend[susptITEMSPRITESCRIPTS] ) return;
43730 7262734 items.run_script(MODE_NORMAL);
43731 7262734 }
43732
43733 7349889 void FFScript::itemSpriteScriptEngineOnWaitdraw()
43734 {
43735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7349889 times.
7349889 if ( FFCore.system_suspend[susptITEMSPRITESCRIPTS] ) return;
43736 7349889 items.run_script(MODE_WAITDRAW);
43737 7349889 }
43738
43739
43740 int32_t FFScript::getTime(int32_t type)
43741 {
43742 //struct tm *tm_struct = localtime(time(NULL));
43743 struct tm * tm_struct;
43744 time_t sysRTC;
43745 time (&sysRTC);
43746 tm_struct = localtime (&sysRTC);
43747 int32_t rval = -1;
43748
43749 switch(type)
43750 {
43751 case curyear:
43752 {
43753 //Year format starts at 1900, yeat
43754 //A raw read of '2018' would be '118', so we add 1900 to it to derive the actual year.
43755 rval = tm_struct->tm_year + 1900; break;
43756
43757 }
43758 case curmonth:
43759 {
43760 //Months start at 0, but we want 1->12
43761 //al_trace("The current month is: %d\n",month);
43762 rval = tm_struct->tm_mon +1; break;
43763 }
43764 case curday_month:
43765 {
43766 rval = tm_struct->tm_mday; break;
43767 }
43768 case curday_week:
43769 {
43770 //It seems that weekdays are a value range of 1 to 7.
43771 rval = tm_struct->tm_wday; break;
43772 }
43773 case curhour:
43774 {
43775 rval = tm_struct->tm_hour; break;
43776 }
43777 case curminute:
43778 {
43779 rval = tm_struct->tm_min; break;
43780 }
43781 case cursecond:
43782 {
43783 rval = tm_struct->tm_sec; break;
43784 }
43785 case curdayyear:
43786 {
43787 //The day (n/365) out of the entire year.
43788 rval = tm_struct->tm_yday; break;
43789 }
43790 case curDST:
43791 {
43792 //Returns if the user is in a Time Zone with Daylight TIme of some sort.
43793 //View the time.h docs for the actual values of this struct element.
43794 rval = tm_struct->tm_isdst;; break;
43795 }
43796 default:
43797 {
43798 al_trace("Invalid category passed to GetSystemTime(%d)\n",type);
43799 rval = -1; break;
43800 }
43801
43802 }
43803 return rval;
43804 }
43805
43806 void FFScript::do_isdeadnpc()
43807 {
43808 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43809 if(GuyH::loadNPC(ri->guyref, "npc->isDead") == SH::_NoError)
43810 {
43811 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43812 //int32_t dead = (int32_t)e->Dead(GuyH::getNPCIndex(ri->guyref));
43813 //GuyH::getNPC()->Dead(GuyH::getNPCIndex(ri->guyref));
43814 set_register(sarg1,
43815 ((GuyH::getNPC()->dying && !GuyH::getNPC()->immortal)
43816 ? 10000 : 0));
43817 }
43818 else set_register(sarg1, 0);
43819 }
43820
43821
43822 void FFScript::do_canslidenpc()
43823 {
43824
43825 if(GuyH::loadNPC(ri->guyref, "npc->CanSlide") == SH::_NoError)
43826 {
43827 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43828 //bool candoit = e->can_slide();
43829 set_register(sarg1, ((GuyH::getNPC()->can_slide()) ? 10000 : 0));
43830 }
43831 else set_register(sarg1, -10000);
43832 }
43833
43834 void FFScript::do_slidenpc()
43835 {
43836
43837 if(GuyH::loadNPC(ri->guyref, "npc->Slide()") == SH::_NoError)
43838 {
43839 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43840 //bool candoit = e->slide();
43841 set_register(sarg1, ((GuyH::getNPC()->slide())*10000));
43842 }
43843 else set_register(sarg1, -10000);
43844 }
43845
43846 void FFScript::do_npc_stopbgsfx()
43847 {
43848 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43849 if(GuyH::loadNPC(ri->guyref, "npc->StopBGSFX()") == SH::_NoError)
43850 {
43851 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43852 //e->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
43853 GuyH::getNPC()->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
43854 }
43855 }
43856
43857 void FFScript::do_npc_delete()
43858 {
43859 if(GuyH::loadNPC(ri->guyref, "npc->Remove()") == SH::_NoError)
43860 {
43861 auto ind = GuyH::getNPCIndex(ri->guyref);
43862 GuyH::getNPC()->stop_bgsfx(ind);
43863 guys.del(ind);
43864 }
43865 }
43866
43867 void FFScript::do_lweapon_delete()
43868 {
43869 if(0!=(s=checkLWpn(ri->lwpn,"Remove()")))
43870 {
43871 if(s==Hero.lift_wpn)
43872 {
43873 delete s;
43874 Hero.lift_wpn = nullptr;
43875 }
43876 else Lwpns.del(LwpnH::getLWeaponIndex(ri->lwpn));
43877 }
43878 }
43879
43880 void FFScript::do_eweapon_delete()
43881 {
43882 if(0!=(s=checkEWpn(ri->ewpn,"Remove()")))
43883 {
43884 Ewpns.del(EwpnH::getEWeaponIndex(ri->ewpn));
43885 }
43886 }
43887
43888 8 bool FFScript::do_itemsprite_delete()
43889 {
43890
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(0!=(s=checkItem(ri->itemref)))
43891 {
43892 8 auto ind = ItemH::getItemIndex(ri->itemref);
43893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!items.del(ind)) return false;
43894
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 8 times.
55 for(int32_t i=0; i<Lwpns.Count(); i++)
43895 {
43896 47 weapon *w = (weapon*)Lwpns.spr(i);
43897
43898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(w->dragging==ind)
43899 {
43900 w->dragging=-1;
43901 }
43902
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 else if(w->dragging>ind)
43903 {
43904 w->dragging-=1;
43905 }
43906 47 }
43907 8 return true;
43908 }
43909 return false;
43910 8 }
43911
43912 408 void FFScript::updateIncludePaths()
43913 {
43914 408 includePaths.clear();
43915 408 int32_t pos = 0;
43916
2/2
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 408 times.
1632 for ( int32_t q = 0; includePathString[pos]; ++q )
43917 {
43918 1224 int32_t dest = 0;
43919 1224 char buf[2048] = {0};
43920
4/4
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 9792 times.
✓ Branch 2 taken 9792 times.
✓ Branch 3 taken 1224 times.
11016 while(includePathString[pos] != ';' && includePathString[pos])
43921 {
43922 9792 buf[dest] = includePathString[pos];
43923 9792 ++pos;
43924 9792 ++dest;
43925 }
43926 1224 ++pos;
43927
1/2
✓ Branch 0 taken 1224 times.
✗ Branch 1 not taken.
1224 std::string str(buf);
43928
1/2
✓ Branch 0 taken 1224 times.
✗ Branch 1 not taken.
1224 includePaths.push_back(str);
43929 1224 }
43930 408 }
43931
43932 408 void FFScript::initRunString()
43933 {
43934 408 memset(scriptRunString,0,sizeof(scriptRunString));
43935 408 strcpy(scriptRunString,zc_get_config("Compiler","run_string","run",App::zscript));
43936 408 }
43937
43938 408 void FFScript::initIncludePaths()
43939 {
43940 408 memset(includePathString,0,sizeof(includePathString));
43941 408 FILE* f = fopen("includepaths.txt", "r");
43942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(f)
43943 {
43944 int32_t pos = 0;
43945 int32_t c;
43946 do
43947 {
43948 c = fgetc(f);
43949 if(c!=EOF)
43950 includePathString[pos++] = c;
43951 }
43952 while(c!=EOF && pos<MAX_INCLUDE_PATH_CHARS);
43953 if(pos<MAX_INCLUDE_PATH_CHARS)
43954 includePathString[pos] = '\0';
43955 includePathString[MAX_INCLUDE_PATH_CHARS-1] = '\0';
43956 fclose(f);
43957 }
43958 408 else strcpy(includePathString, "include/;headers/;scripts/;");
43959 408 al_trace("Full path string is: ");
43960 408 safe_al_trace(includePathString);
43961 408 al_trace("\n");
43962 408 updateIncludePaths();
43963
43964
2/2
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 408 times.
1632 for ( size_t q = 0; q < includePaths.size(); ++q )
43965 {
43966 1224 al_trace("Include path %zu: ",q);
43967 1224 safe_al_trace(includePaths.at(q));
43968 1224 al_trace("\n");
43969 1224 }
43970 408 }
43971
43972 void FFScript::do_npcattack()
43973 {
43974
43975 if(GuyH::loadNPC(ri->guyref, "npc->Attack()") == SH::_NoError)
43976 {
43977 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43978 //e->FireWeapon();
43979 //we could just do:
43980 GuyH::getNPC()->FireWeapon();
43981 }
43982 }
43983 void FFScript::do_npc_newdir()
43984 {
43985 int32_t arrayptr = get_register(sarg1) / 10000;
43986 ArrayManager am(arrayptr);
43987 if(am.invalid()) return;
43988 int32_t sz = am.size();
43989
43990 if(GuyH::loadNPC(ri->guyref, "npc->NewDir()") == SH::_NoError)
43991 {
43992 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43993
43994 if ( sz != -1 )
43995 {
43996 if ( sz != 3 )
43997 {
43998 Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
43999 return;
44000 }
44001 GuyH::getNPC()->newdir((am.get(0)/10000), (am.get(1)/10000),
44002 (am.get(2)/10000));
44003 }
44004 //else e->newdir();
44005 else GuyH::getNPC()->newdir();
44006 }
44007 }
44008
44009 void FFScript::do_npc_constwalk()
44010 {
44011 int32_t arrayptr = get_register(sarg1) / 10000;
44012 ArrayManager am(arrayptr);
44013 if(am.invalid()) return;
44014 int32_t sz = am.size();
44015
44016 if(GuyH::loadNPC(ri->guyref, "npc->ConstantWalk()") == SH::_NoError)
44017 {
44018 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44019
44020 if ( sz != -1 )
44021 {
44022 if ( sz != 3 )
44023 {
44024 Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
44025 return;
44026 }
44027 GuyH::getNPC()->constant_walk( (am.get(0)/10000), (am.get(1)/10000),
44028 (am.get(2)/10000) );
44029 }
44030 else GuyH::getNPC()->constant_walk();//e->constant_walk();
44031 }
44032 }
44033
44034 void FFScript::do_npc_varwalk()
44035 {
44036 int32_t arrayptr = get_register(sarg2) / 10000;
44037 ArrayManager am(arrayptr);
44038 if(am.invalid()) return;
44039 int32_t sz = am.size();
44040
44041 if(GuyH::loadNPC(ri->guyref, "npc->VariableWalk()") == SH::_NoError)
44042 {
44043 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44044
44045 if ( sz == 3 )
44046 {
44047
44048 GuyH::getNPC()->variable_walk( (am.get(0)/10000), (am.get(1)/10000),
44049 (am.get(2)/10000) );
44050 }
44051 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
44052 }
44053 }
44054
44055 void FFScript::do_npc_varwalk8()
44056 {
44057 int32_t arrayptr = get_register(sarg1) / 10000;
44058 ArrayManager am(arrayptr);
44059 if(am.invalid()) return;
44060 int32_t sz = am.size();
44061
44062 if(GuyH::loadNPC(ri->guyref, "npc->VariableWalk8()") == SH::_NoError)
44063 {
44064 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44065
44066 if ( sz == 4 )
44067 {
44068 GuyH::getNPC()->variable_walk_8( (am.get(0)/10000), (am.get(1)/10000),
44069 (am.get(2)/10000), (am.get(3)/10000) );
44070 }
44071 else if ( sz == 8 )
44072 {
44073 GuyH::getNPC()->variable_walk_8( (am.get(0)/10000), (am.get(1)/10000),
44074 (am.get(2)/10000), (am.get(3)/10000),
44075 (am.get(4)/10000), (am.get(5)/10000),
44076 (am.get(6)/10000), (am.get(7)/10000)
44077 );
44078 }
44079 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
44080 }
44081 }
44082
44083 void FFScript::do_npc_constwalk8()
44084 {
44085 int32_t arrayptr = get_register(sarg1) / 10000;
44086 ArrayManager am(arrayptr);
44087 if(am.invalid()) return;
44088 int32_t sz = am.size();
44089
44090 if(GuyH::loadNPC(ri->guyref, "npc->ConstantWalk8()") == SH::_NoError)
44091 {
44092 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44093
44094 if ( sz == 3 )
44095 {
44096 GuyH::getNPC()->constant_walk_8( (am.get(0)/10000), (am.get(1)/10000),
44097 (am.get(2)/10000) );
44098 }
44099
44100 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
44101 }
44102 }
44103
44104
44105 void FFScript::do_npc_haltwalk()
44106 {
44107 int32_t arrayptr = get_register(sarg1) / 10000;
44108 ArrayManager am(arrayptr);
44109 if(am.invalid()) return;
44110 int32_t sz = am.size();
44111
44112 if(GuyH::loadNPC(ri->guyref, "npc->HaltingWalk()") == SH::_NoError)
44113 {
44114 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44115
44116 if ( sz == 5 )
44117 {
44118 GuyH::getNPC()->halting_walk( (am.get(0)/10000), (am.get(1)/10000),
44119 (am.get(2)/10000), (am.get(3)/10000),
44120 (am.get(4)/10000));
44121 }
44122 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
44123 }
44124 }
44125
44126 void FFScript::do_npc_haltwalk8()
44127 {
44128 int32_t arrayptr = get_register(sarg1) / 10000;
44129 ArrayManager am(arrayptr);
44130 if(am.invalid()) return;
44131 int32_t sz = am.size();
44132
44133 if(GuyH::loadNPC(ri->guyref, "npc->HaltingWalk8()") == SH::_NoError)
44134 {
44135 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44136
44137 if ( sz == 6 )
44138 {
44139
44140 GuyH::getNPC()->halting_walk_8( (am.get(0)/10000), (am.get(1)/10000),
44141 (am.get(2)/10000), (am.get(3)/10000),
44142 (am.get(4)/10000),(am.get(5)/10000));
44143 }
44144 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
44145 }
44146 }
44147
44148
44149 void FFScript::do_npc_floatwalk()
44150 {
44151 int32_t arrayptr = get_register(sarg1) / 10000;
44152 ArrayManager am(arrayptr);
44153 if(am.invalid()) return;
44154 int32_t sz = am.size();
44155
44156 if(GuyH::loadNPC(ri->guyref, "npc->FloatingWalk()") == SH::_NoError)
44157 {
44158 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44159
44160 if ( sz == 3 )
44161 {
44162
44163 GuyH::getNPC()->floater_walk( (am.get(0)/10000), (am.get(1)/10000),
44164 (zfix)(am.get(2)/10000));
44165
44166 }
44167 else if ( sz == 7 )
44168 {
44169
44170 GuyH::getNPC()->floater_walk( (am.get(0)/10000), (am.get(1)/10000),
44171 (zfix)(am.get(2)/10000), (zfix)(am.get(3)/10000),
44172 (am.get(4)/10000),(am.get(5)/10000),
44173 (am.get(6)/10000));
44174 }
44175 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
44176 }
44177 }
44178
44179 void FFScript::do_npc_breathefire()
44180 {
44181 bool seek = (get_register(sarg1));
44182 if(GuyH::loadNPC(ri->guyref, "npc->BreathAttack()") == SH::_NoError)
44183 {
44184 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44185 GuyH::getNPC()->FireBreath(seek);
44186
44187 }
44188 }
44189
44190
44191 void FFScript::do_npc_newdir8()
44192 {
44193 int32_t arrayptr = get_register(sarg1) / 10000;
44194 ArrayManager am(arrayptr);
44195 if(am.invalid()) return;
44196 int32_t sz = am.size();
44197
44198 if(GuyH::loadNPC(ri->guyref, "npc->NewDir8()") == SH::_NoError)
44199 {
44200 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44201
44202 if ( sz == 3 )
44203 {
44204
44205 GuyH::getNPC()->newdir_8( (am.get(0)/10000), (am.get(1)/10000),
44206 (am.get(2)/10000));
44207
44208 }
44209 else if ( sz == 7 )
44210 {
44211
44212 GuyH::getNPC()->newdir_8( (am.get(0)/10000), (am.get(1)/10000),
44213 (am.get(2)/10000), (am.get(3)/10000),
44214 (am.get(4)/10000),(am.get(5)/10000),
44215 (am.get(6)/10000));
44216 }
44217 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
44218 }
44219 }
44220
44221
44222 int32_t FFScript::npc_collision()
44223 {
44224 int32_t isColl = 0;
44225 if(GuyH::loadNPC(ri->guyref, "npc->Collision()") == SH::_NoError)
44226 {
44227 int32_t _obj_type = (ri->d[rINDEX] / 10000);
44228 int32_t _obj_ptr = (ri->d[rINDEX2]);
44229
44230 switch(_obj_type)
44231 {
44232 case obj_type_lweapon:
44233 {
44234 isColl = 0;
44235 break;
44236 }
44237 case obj_type_eweapon:
44238 {
44239 isColl = 0;
44240 break;
44241 }
44242 case obj_type_npc:
44243 {
44244 isColl = 0;
44245 break;
44246 }
44247 case obj_type_player:
44248 {
44249 isColl = 0;
44250 break;
44251 }
44252 case obj_type_ffc:
44253 {
44254 _obj_ptr *= 10000; _obj_ptr -= 1;
44255 isColl = 0;
44256 break;
44257 }
44258 case obj_type_combo_pos:
44259 {
44260 _obj_ptr *= 10000;
44261 isColl = 0;
44262 break;
44263 }
44264 case obj_type_item:
44265 {
44266 isColl = 0;
44267 break;
44268 }
44269 default:
44270 {
44271 Z_scripterrlog("Invalid object type (%d) passed to npc->Collision(int32_t type, int32_t ptr)\n", _obj_type);
44272 isColl = 0;
44273 break;
44274 }
44275 }
44276 }
44277
44278 return isColl;
44279 }
44280
44281
44282 int32_t FFScript::npc_linedup()
44283 {
44284 if(GuyH::loadNPC(ri->guyref, "npc->LinedUp()") == SH::_NoError)
44285 {
44286 int32_t range = (ri->d[rINDEX] / 10000);
44287 bool dir8 = (ri->d[rINDEX2]);
44288 return (int32_t)(GuyH::getNPC()->lined_up(range,dir8)*10000);
44289 }
44290
44291 return 0;
44292 }
44293
44294
44295 void FFScript::do_npc_hero_in_range(const bool v)
44296 {
44297 int32_t dist = get_register(sarg1) / 10000;
44298 if(GuyH::loadNPC(ri->guyref, "npc->LinedUp()") == SH::_NoError)
44299 {
44300 bool in_range = GuyH::getNPC()->HeroInRange(dist);
44301 set_register(sarg1, (in_range ? 10000 : 0)); //This isn't setting the right value, it seems.
44302 }
44303 else set_register(sarg2, 0);
44304 }
44305
44306
44307
44308
44309
44310
44311 void FFScript::do_npc_simulate_hit(const bool v)
44312 {
44313 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
44314 ArrayManager am(arrayptr);
44315 if(am.invalid()) return;
44316 int32_t sz = am.size();
44317 bool ishit = false;
44318
44319 if(GuyH::loadNPC(ri->guyref, "npc->SimulateHit()") == SH::_NoError)
44320 {
44321 // zprint("Trying to simulate a hit on npc\n");
44322 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44323 if ( sz == 2 ) //type and pointer
44324 {
44325 // int32_t type = am.get(0)/10000;
44326
44327 //switch(type)
44328 //{
44329 // case simulate_hit_type_weapon:
44330 // {
44331 // ishit = e->hit(*);
44332 // break;
44333 // }
44334 // case simulate_hit_type_sprite:
44335 // {
44336 // ishit = e->hit(*);
44337 // break;
44338 // }
44339 //}
44340 ishit = false;
44341 }
44342 if ( sz == 6 ) //hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz);
44343 {
44344 ishit = GuyH::getNPC()->hit( (am.get(0)/10000), (am.get(1)/10000),
44345 (am.get(2)/10000), (am.get(3)/10000),
44346 (am.get(4)/10000), (am.get(5)/10000) );
44347
44348 }
44349 else
44350 {
44351 Z_scripterrlog("Invalid array size (%d) passed to npc->SimulateHit(). The array size must be [1] or [3].\n", sz);
44352 ishit = false;
44353 }
44354 }
44355 set_register(sarg1, ( ishit ? 10000 : 0));
44356 }
44357
44358 void FFScript::do_npc_knockback(const bool v)
44359 {
44360 int32_t time = SH::get_arg(sarg1, v) / 10000;
44361 int32_t dir = SH::get_arg(sarg2, v) / 10000;
44362 int32_t spd = vbound(ri->d[rINDEX] / 10000, 0, 255);
44363 //zprint("Knockback: time %d,dir %d,spd %d\n",time,dir,spd);
44364 bool ret = false;
44365
44366 if(GuyH::loadNPC(ri->guyref, "npc->Knockback()") == SH::_NoError)
44367 {
44368 ret = GuyH::getNPC()->knockback(time, dir, spd);
44369 }
44370 set_register(sarg1, ( ret ? 10000 : 0));
44371 }
44372
44373 void FFScript::do_npc_add(const bool v)
44374 {
44375
44376 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
44377 ArrayManager am(arrayptr);
44378 if(am.invalid()) return;
44379 int32_t sz = am.size();
44380
44381 int32_t id = 0, nx = 0, ny = 0;
44382
44383 if ( sz < 1 )
44384 {
44385 Z_scripterrlog("Invalid array size (%d) passed to npc->Create(). The array size must be [1] or [3].\n", sz);
44386 return;
44387 }
44388 else //size is valid
44389 {
44390 id = (am.get(0)/10000);
44391
44392 if ( sz == 3 ) //x and y
44393 {
44394 nx = (am.get(1)/10000);
44395 ny = (am.get(2)/10000);
44396 }
44397 }
44398
44399
44400 if(BC::checkGuyID(id, "npc->Create()") != SH::_NoError)
44401 return;
44402
44403 //If we make a segmented enemy there'll be more than one sprite created
44404 word numcreated = addenemy(nx, ny, id, -10);
44405
44406 if(numcreated == 0)
44407 {
44408 ri->guyref = MAX_DWORD;
44409 Z_scripterrlog("Couldn't create NPC \"%s\", screen NPC limit reached\n", guy_string[id]);
44410 }
44411 else
44412 {
44413 word index = guys.Count() - numcreated; //Get the main enemy, not a segment
44414 ri->guyref = guys.spr(index)->getUID();
44415
44416 for(; index<guys.Count(); index++)
44417 ((enemy*)guys.spr(index))->script_spawned=true;
44418
44419 ri->d[rEXP1] = ri->guyref;
44420 ri->d[rEXP2] = ri->guyref;
44421 Z_eventlog("Script created NPC \"%s\" with UID = %ld\n", guy_string[id], ri->guyref);
44422 }
44423 }
44424
44425 bool FFScript::checkExtension(std::string &filename, const std::string &extension)
44426 //inline bool checkExtension(std::string filename, std::string extension)
44427 {
44428 int32_t dot = filename.find_last_of(".");
44429 std::string exten = (dot == std::string::npos ? "" : filename.substr(dot, filename.length() - dot));
44430 return exten == extension;
44431 }
44432
44433
44434 void FFScript::do_loadgamestructs(const bool v, const bool v2)
44435 {
44436 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
44437 int32_t section_id = SH::get_arg(sarg2, v2) / 10000;
44438 zprint("do_loadgamestructs selected section is: %d\n", section_id);
44439 //Bitwise OR sections together
44440 string strA;
44441 ArrayH::getString(arrayptr, strA, 256);
44442 int32_t temp_sram_flags = section_id; int32_t sram_version = 0;
44443
44444 if ( FFCore.checkExtension(strA, ".zcsram") )
44445 {
44446 PACKFILE *f = pack_fopen_password(strA.c_str(),F_READ, "");
44447 if (f)
44448 {
44449 p_igetl(&sram_version,f);
44450 p_igetl(&section_id,f);
44451 zprint("Reading ZCSRAM, Version: %d\n", sram_version);
44452 if ( sram_version > SRAM_VERSION ) //file version is greater than programme current version.
44453 {
44454 Z_scripterrlog("SRAM Version is from a version of ZC newer than the running version and cannot be loaded.\n");
44455 return;
44456 }
44457 if ( section_id != temp_sram_flags )
44458 {
44459 Z_scripterrlog("Reading an SRAM file with a section flag mismatch!\nThe file section flags are (%d) and the specified flagset is (%d).\nThis may cause errors!\n", section_id, temp_sram_flags);
44460 }
44461
44462 if ( !section_id || section_id&svGUYS ) FFCore.read_enemies(f,sram_version);
44463 if ( !section_id || section_id&svITEMS )FFCore.read_items(f,sram_version);
44464 if ( !section_id || section_id&svWEAPONS ) FFCore.read_weaponsprtites(f,sram_version);
44465 if ( !section_id || section_id&svCOMBOS )
44466 {
44467 reset_combo_animations();
44468 reset_combo_animations2();
44469 FFCore.read_combos(f,sram_version);
44470 }
44471 if ( !section_id || section_id&svDMAPS ) FFCore.read_dmaps(f,sram_version);
44472 if ( !section_id || section_id&svMAPSCR ) FFCore.read_mapscreens(f,sram_version);
44473 pack_fclose(f);
44474 zprint("do_savegamestructs COMPLETED READINV %s, with section ID flags %d\n", "ALL", section_id);
44475
44476 set_register(sarg1, 10000);
44477 }
44478 else
44479 {
44480 Z_scripterrlog("FFCore.do_loadgamestructs could not read packfile!");
44481 set_register(sarg1, -10000);
44482 }
44483 }
44484 else
44485 {
44486 Z_scripterrlog("Tried to read a .zcsram file, but the file lacked the ..zcsram extension!\n");
44487 set_register(sarg1, -20000);
44488
44489 }
44490 }
44491
44492 void FFScript::do_savegamestructs(const bool v, const bool v2)
44493 {
44494 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
44495 int32_t section_id = SH::get_arg(sarg2, v2) / 10000;
44496 zprint("do_loadgamestructs selected section is: %d\n", section_id);
44497 //Bitwise OR sections together
44498 string strA;
44499 ArrayH::getString(arrayptr, strA, 256);
44500 int32_t cycles = 0;
44501
44502 if ( FFCore.checkExtension(strA, ".zcsram") )
44503 {
44504 PACKFILE *f = pack_fopen_password(strA.c_str(),F_WRITE, "");
44505 if (f)
44506 {
44507 p_iputl(SRAM_VERSION,f);
44508 p_iputl(section_id,f);
44509
44510 if ( !section_id || section_id&svGUYS ) FFCore.write_enemies(f,SRAM_VERSION);
44511 if ( !section_id || section_id&svITEMS ) FFCore.write_items(f,SRAM_VERSION);
44512 if ( !section_id || section_id&svWEAPONS ) FFCore.write_weaponsprtites(f,SRAM_VERSION);
44513 if ( !section_id || section_id&svCOMBOS )
44514 {
44515 reset_combo_animations();
44516 reset_combo_animations2();
44517 FFCore.write_combos(f,SRAM_VERSION);
44518 }
44519 if ( !section_id || section_id&svDMAPS ) FFCore.write_dmaps(f,SRAM_VERSION);
44520 if ( !section_id || section_id&svMAPSCR ) FFCore.write_mapscreens(f,SRAM_VERSION);
44521 pack_fclose(f);
44522 zprint("do_savegamestructs COMPLETED WRITING %s, with section ID flags %d\n", "ALL", section_id);
44523 set_register(sarg1, 10000);
44524 }
44525 else
44526 {
44527 Z_scripterrlog("FFCore.do_loadgamestructs could not read packfile!");
44528 set_register(sarg1, -10000);
44529 }
44530 }
44531 else
44532 {
44533 Z_scripterrlog("Tried to write a .zcsram file, but the file lacked the ..zcsram extension!\n");
44534 set_register(sarg1, -20000);
44535 }
44536 }
44537
44538 1 void FFScript::do_strcmp()
44539 {
44540 1 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000 ?
44541 1 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
44542 1 string strA;
44543 1 string strB;
44544
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ArrayH::getString(arrayptr_a, strA);
44545
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ArrayH::getString(arrayptr_b, strB);
44546
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 set_register(sarg1, (strcmp(strA.c_str(), strB.c_str()) * 10000));
44547 1 }
44548
44549 void FFScript::do_stricmp()
44550 {
44551 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
44552 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
44553 string strA;
44554 string strB;
44555 ArrayH::getString(arrayptr_a, strA);
44556 ArrayH::getString(arrayptr_b, strB);
44557 set_register(sarg1, (stricmp(strA.c_str(), strB.c_str()) * 10000));
44558 }
44559
44560 1 void FFScript::do_LowerToUpper(const bool v)
44561 {
44562
44563 1 int32_t arrayptr_a = get_register(sarg1) / 10000;
44564 1 string strA;
44565
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ArrayH::getString(arrayptr_a, strA);
44566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( strA.size() < 1 )
44567 {
44568 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", strA.size());
44569 set_register(sarg1, 0); return;
44570 }
44571
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 for ( size_t q = 0; q < strA.size(); ++q )
44572 {
44573
3/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
5 strA[q] -= 32 * (strA[q] >= 'a' && strA[q] <= 'z');
44574 //if(( strA[q] >= 'a' && strA[q] <= 'z' ) || ( strA[q] >= 'A' && strA[q] <= 'Z' ))
44575 //{
44576 // if ( strA[q] < 'a' ) { continue; }
44577 // else strA[q] -= 32;
44578 // continue;
44579 //}
44580
44581 5 }
44582 //zprint("Converted string is: %s \n", strA.c_str());
44583
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
44584 {
44585 Z_scripterrlog("Dest string supplied to 'LowerToUpper()' not large enough\n");
44586 set_register(sarg1, 0);
44587 }
44588
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 else set_register(sarg1, (10000));
44589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 }
44590
44591 void FFScript::do_UpperToLower(const bool v)
44592 {
44593
44594 int32_t arrayptr_a = get_register(sarg1) / 10000;
44595 string strA;
44596 ArrayH::getString(arrayptr_a, strA);
44597 if ( strA.size() < 1 )
44598 {
44599 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", strA.size());
44600 set_register(sarg1, 0); return;
44601 }
44602 for ( size_t q = 0; q < strA.size(); ++q )
44603 {
44604 strA[q] += 32 * (strA[q] >= 'A' && strA[q] <= 'Z');
44605 //if(( strA[q] >= 'a' && strA[q] <= 'z' ) || ( strA[q] >= 'A' && strA[q] <= 'Z' ))
44606 //{
44607 // if ( strA[q] < 'a' ) { strA[q] += 32; }
44608 // else continue;
44609 // continue;
44610 //}
44611 }
44612 //zprint("Converted string is: %s \n", strA.c_str());
44613 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
44614 {
44615 Z_scripterrlog("Dest string supplied to 'LowerToUpper()' not large enough\n");
44616 set_register(sarg1, 0);
44617 }
44618 else set_register(sarg1, (10000));
44619 }
44620
44621 void FFScript::do_getnpcscript()
44622 {
44623 int32_t arrayptr = get_register(sarg1) / 10000;
44624 string the_string;
44625 int32_t script_num = -1;
44626 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44627
44628 for(int32_t q = 0; q < NUMSCRIPTGUYS; q++)
44629 {
44630 if(!(strcmp(the_string.c_str(), npcmap[q].scriptname.c_str())))
44631 {
44632 script_num = q+1;
44633 break;
44634 }
44635 }
44636 set_register(sarg1, (script_num * 10000));
44637 }
44638
44639 void FFScript::do_getcomboscript()
44640 {
44641 int32_t arrayptr = get_register(sarg1) / 10000;
44642 string the_string;
44643 int32_t script_num = -1;
44644 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44645
44646 for(int32_t q = 0; q < NUMSCRIPTSCOMBODATA; q++)
44647 {
44648 if(!(strcmp(the_string.c_str(), comboscriptmap[q].scriptname.c_str())))
44649 {
44650 script_num = q+1;
44651 break;
44652 }
44653 }
44654 set_register(sarg1, (script_num * 10000));
44655 }
44656
44657 68 void FFScript::do_getgenericscript()
44658 {
44659 68 int32_t arrayptr = get_register(sarg1) / 10000;
44660 68 string the_string;
44661 68 int32_t script_num = -1;
44662
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44663
44664 // zprint2("Searching for generic script named '%s'\n", the_string.c_str());
44665
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 for(int32_t q = 0; q < NUMSCRIPTSGENERIC; q++)
44666 {
44667 // if(genericmap[q].scriptname.size()>2)
44668 // zprint2("Checking against '%s'...\n", genericmap[q].scriptname.c_str());
44669
3/4
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 68 times.
361 if(!(strcmp(the_string.c_str(), genericmap[q].scriptname.c_str())))
44670 {
44671 68 script_num = q+1;
44672 68 break;
44673 }
44674 293 }
44675
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 set_register(sarg1, (script_num * 10000));
44676 68 }
44677
44678 586 void FFScript::do_getlweaponscript()
44679 {
44680 586 int32_t arrayptr = get_register(sarg1) / 10000;
44681 586 string the_string;
44682 586 int32_t script_num = -1;
44683
1/2
✓ Branch 0 taken 586 times.
✗ Branch 1 not taken.
586 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44684
44685
1/2
✓ Branch 0 taken 17245 times.
✗ Branch 1 not taken.
17245 for(int32_t q = 0; q < NUMSCRIPTWEAPONS; q++)
44686 {
44687
3/4
✓ Branch 0 taken 17245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16659 times.
✓ Branch 3 taken 586 times.
17245 if(!(strcmp(the_string.c_str(), lwpnmap[q].scriptname.c_str())))
44688 {
44689 586 script_num = q+1;
44690 586 break;
44691 }
44692 16659 }
44693
1/2
✓ Branch 0 taken 586 times.
✗ Branch 1 not taken.
586 set_register(sarg1, (script_num * 10000));
44694 586 }
44695 1275 void FFScript::do_geteweaponscript()
44696 {
44697 1275 int32_t arrayptr = get_register(sarg1) / 10000;
44698 1275 string the_string;
44699 1275 int32_t script_num = -1;
44700
1/2
✓ Branch 0 taken 1275 times.
✗ Branch 1 not taken.
1275 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44701
44702
1/2
✓ Branch 0 taken 29109 times.
✗ Branch 1 not taken.
29109 for(int32_t q = 0; q < NUMSCRIPTWEAPONS; q++)
44703 {
44704
3/4
✓ Branch 0 taken 29109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27834 times.
✓ Branch 3 taken 1275 times.
29109 if(!(strcmp(the_string.c_str(), ewpnmap[q].scriptname.c_str())))
44705 {
44706 1275 script_num = q+1;
44707 1275 break;
44708 }
44709 27834 }
44710
1/2
✓ Branch 0 taken 1275 times.
✗ Branch 1 not taken.
1275 set_register(sarg1, (script_num * 10000));
44711 1275 }
44712 void FFScript::do_getheroscript()
44713 {
44714 int32_t arrayptr = get_register(sarg1) / 10000;
44715 string the_string;
44716 int32_t script_num = -1;
44717 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44718
44719 for(int32_t q = 0; q < NUMSCRIPTPLAYER; q++)
44720 {
44721 if(!(strcmp(the_string.c_str(), playermap[q].scriptname.c_str())))
44722 {
44723 script_num = q+1;
44724 break;
44725 }
44726 }
44727 set_register(sarg1, (script_num * 10000));
44728 }
44729 void FFScript::do_getglobalscript()
44730 {
44731 int32_t arrayptr = get_register(sarg1) / 10000;
44732 string the_string;
44733 int32_t script_num = -1;
44734 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44735
44736 for(int32_t q = 0; q < NUMSCRIPTGLOBAL; q++)
44737 {
44738 if(!(strcmp(the_string.c_str(), globalmap[q].scriptname.c_str())))
44739 {
44740 script_num = q+1;
44741 break;
44742 }
44743 }
44744 set_register(sarg1, (script_num * 10000));
44745 }
44746 102 void FFScript::do_getdmapscript()
44747 {
44748 102 int32_t arrayptr = get_register(sarg1) / 10000;
44749 102 string the_string;
44750 102 int32_t script_num = -1;
44751
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44752
44753
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 for(int32_t q = 0; q < NUMSCRIPTSDMAP; q++)
44754 {
44755
3/4
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 102 times.
575 if(!(strcmp(the_string.c_str(), dmapmap[q].scriptname.c_str())))
44756 {
44757 102 script_num = q+1;
44758 102 break;
44759 }
44760 473 }
44761
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 set_register(sarg1, (script_num * 10000));
44762 102 }
44763 void FFScript::do_getscreenscript()
44764 {
44765 int32_t arrayptr = get_register(sarg1) / 10000;
44766 string the_string;
44767 int32_t script_num = -1;
44768 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44769
44770 for(int32_t q = 0; q < NUMSCRIPTSCREEN; q++)
44771 {
44772 if(!(strcmp(the_string.c_str(), screenmap[q].scriptname.c_str())))
44773 {
44774 script_num = q+1;
44775 break;
44776 }
44777 }
44778 set_register(sarg1, (script_num * 10000));
44779 }
44780 31 void FFScript::do_getitemspritescript()
44781 {
44782 31 int32_t arrayptr = get_register(sarg1) / 10000;
44783 31 string the_string;
44784 31 int32_t script_num = -1;
44785
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44786
44787
1/2
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
273 for(int32_t q = 0; q < NUMSCRIPTSITEMSPRITE; q++)
44788 {
44789
3/4
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242 times.
✓ Branch 3 taken 31 times.
273 if(!(strcmp(the_string.c_str(), itemspritemap[q].scriptname.c_str())))
44790 {
44791 31 script_num = q+1;
44792 31 break;
44793 }
44794 242 }
44795
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_register(sarg1, (script_num * 10000));
44796 31 }
44797 //Not assigned to slots at present. If they ever are, then this would get the id of any script (any type) by name. -Z
44798 void FFScript::do_getuntypedscript()
44799 {
44800 set_register(sarg1, 0);
44801 //int32_t arrayptr = ri->d[rINDEX]/10000;
44802 //string the_string;
44803 //int32_t script_num = -1;
44804 //ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44805
44806 //for(int32_t q = 0; q < NUMSCRIPTSITEMSPRITE; q++)
44807 //{
44808 // if(!(strcmp(the_string.c_str(), itemspritemap[q].scriptname.c_str())))
44809 // {
44810 // script_num = q+1;
44811 // break;
44812 // }
44813 //}
44814 //set_register(sarg1, (script_num * 10000));
44815 }
44816 void FFScript::do_getsubscreenscript()
44817 {
44818 //int32_t arrayptr = ri->d[rINDEX]/10000;
44819 //string the_string;
44820 //int32_t script_num = -1;
44821 //ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44822
44823 //for(int32_t q = 0; q < NUMSCRIPTSUBSCREEN; q++)
44824 //{
44825 // if(!(strcmp(the_string.c_str(), subscreenmap[q].scriptname.c_str())))
44826 // {
44827 // script_num = q+1;
44828 // break;
44829 // }
44830 //}
44831 //set_register(sarg1, (script_num * 10000));
44832 set_register(sarg1, 0); //Remove this line, when we add this script type, then un-comment the rest. -Z
44833 }
44834 void FFScript::do_getnpcbyname()
44835 {
44836 int32_t arrayptr = get_register(sarg1) / 10000;
44837 string the_string;
44838 int32_t num = -1;
44839 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44840
44841 for(int32_t q = 0; q < MAXNPCS; q++)
44842 {
44843 if(!(strcmp(the_string.c_str(), guy_string[q])))
44844 {
44845 num = q;
44846 break;
44847 }
44848 }
44849 set_register(sarg1, (num * 10000));
44850 }
44851 void FFScript::do_getitembyname()
44852 {
44853 int32_t arrayptr = get_register(sarg1) / 10000;
44854 string the_string;
44855 int32_t num = -1;
44856 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44857
44858 for(int32_t q = 0; q < MAXNPCS; q++)
44859 {
44860 if(!(strcmp(the_string.c_str(), item_string[q])))
44861 {
44862 num = q;
44863 break;
44864 }
44865 }
44866 set_register(sarg1, (num * 10000));
44867 }
44868 void FFScript::do_getcombobyname()
44869 {
44870 int32_t arrayptr = get_register(sarg1) / 10000;
44871 string the_string;
44872 int32_t num = -1;
44873 ArrayH::getString(arrayptr, the_string, 256);
44874
44875 if (!the_string.empty())
44876 {
44877 for(int32_t q = 0; q < MAXCOMBOS; q++)
44878 {
44879 if (the_string == combobuf[q].label)
44880 {
44881 num = q;
44882 break;
44883 }
44884 }
44885 }
44886 set_register(sarg1, (num * 10000));
44887 }
44888 void FFScript::do_getdmapbyname()
44889 {
44890 int32_t arrayptr = get_register(sarg1) / 10000;
44891 string the_string;
44892 int32_t num = -1;
44893 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44894
44895 for(int32_t q = 0; q < MAXDMAPS; q++)
44896 {
44897 if(!(strcmp(the_string.c_str(), DMaps[q].name)))
44898 {
44899 num = q;
44900 break;
44901 }
44902 }
44903 set_register(sarg1, (num * 10000));
44904 }
44905
44906 ////////////////////////
44907 /// String Utilities ///
44908 ////////////////////////
44909 void FFScript::do_ConvertCase(const bool v)
44910 {
44911 int32_t arrayptr_a = get_register(sarg1) / 10000;
44912 string strA;
44913 ArrayH::getString(arrayptr_a, strA);
44914 if ( strA.size() < 1 )
44915 {
44916 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", strA.size());
44917 set_register(sarg1, 0); return;
44918 }
44919 for ( size_t q = 0; q < strA.size(); ++q )
44920 {
44921 if ( strA[q] < 'a' )
44922 strA[q] += 32 * (strA[q] >= 'A' && strA[q] <= 'Z');
44923
44924 else
44925 strA[q] -= 32 * (strA[q] >= 'a' && strA[q] <= 'z');
44926 //strA[q] -= (32 * (strA[q] >= 'a' && strA[q] <= 'z')) * (-1*((strA[q] >= 'A' && strA[q] <= 'Z')));
44927 //int32_t n = 'c';
44928
44929 //strA[q] -= 32 * ((strA[q] >= 'a' && strA[q] <= 'z')) * (-1*((strA[q] >= 'A' && strA[q] <= 'Z')));
44930 //zprint2("n is %d\n", n);
44931 //if(( strA[q] >= 'a' || strA[q] <= 'z' ) || ( strA[q] >= 'A' || strA[q] <= 'Z' ))
44932 //{
44933 // if ( strA[q] < 'a' ) { strA[q] += 32; }
44934 // else strA[q] -= 32;
44935 // continue;
44936 //}
44937
44938 }
44939 //zprint("Converted string is: %s \n", strA.c_str());
44940 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
44941 {
44942 Z_scripterrlog("Dest string supplied to 'LowerToUpper()' not large enough\n");
44943 set_register(sarg1, 0);
44944 }
44945 else set_register(sarg1, (10000));
44946 }
44947
44948 void FFScript::do_xlen(const bool v)
44949 {
44950 //not implemented, xlen not found
44951 //zprint("Running: %s\n","strlen()");
44952 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
44953 string str;
44954 ArrayH::getString(arrayptr, str);
44955 //zprint("strlen string size is: %d\n", str.length());
44956 //set_register(sarg1, (xlen(str.c_str()) * 10000));
44957 }
44958
44959 void FFScript::do_xtoi(const bool v)
44960 {
44961 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
44962 string str;
44963 ArrayH::getString(arrayptr, str);
44964 //zprint2("xtoi array pointer is: %d\n", arrayptr);
44965 //zprint2("xtoi string is %s\n", str.c_str());
44966 double val = zc_xtoi(const_cast<char*>(str.c_str()));
44967 //zprint2("xtoi val is %f\n", val);
44968 set_register(sarg1, (int32_t)(val) * 10000);
44969 }
44970 void FFScript::do_xtoi2()
44971 {
44972 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
44973 string strA;
44974 ArrayH::getString(arrayptr_a, strA);
44975 set_register(sarg1, (zc_xtoi(strA.c_str()) * 10000));
44976 }
44977
44978 // Calculates log2 of number.
44979 double FFScript::Log2( double n )
44980 {
44981 // log(n)/log(2) is log2.
44982 return log( (double)n ) / log( (double)2 );
44983 }
44984
44985 //xtoa, convert hex number to hex ascii
44986 void FFScript::do_xtoa()
44987 {
44988
44989 int32_t arrayptr_a = get_register(sarg1) / 10000;
44990 int32_t number = get_register(sarg2) / 10000;//ri->d[rEXP2]/10000; //why are you not in sarg2?!!
44991
44992 //for ( int32_t q = 0; q < 6; ++q )
44993 // zprint2("ri->d[%d] is %d", q, ri->d[q]);
44994
44995 // zprint2("xtoa_c arrayptr_a is: %d\n",arrayptr_a);
44996 // zprint2("xtoa_c number is: %d\n",number);
44997
44998
44999
45000
45001 bool isneg = false;
45002 if ( number < 0 )
45003 {
45004 isneg = true;
45005 number *= -1;
45006 }
45007 double num = number;
45008 // zprint2("xtoa_c(), num is: %f\n", num);
45009 int32_t digits = num ? floor(FFCore.LogToBase(num, 16) + 1) : 1;
45010 //sizeof(number)*CHAR_BIT/4;
45011 // zprint2("xtoa_c, digits is: %d\n",digits);
45012
45013
45014 int32_t pos = 0;
45015 string strA;
45016 if(number == 0) //Needs to precede str.resize(digits+3) as if the number is <= 0 then this breaks.
45017 {
45018 strA.resize(3);
45019 strA[pos+2] = '0';
45020 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
45021 {
45022 Z_scripterrlog("Dest string supplied to 'itoa()' not large enough\n");
45023 set_register(sarg1, 0);
45024 }
45025 else set_register(sarg1, 30000); //returns the pointer to the dest
45026 return;
45027 }
45028 int32_t ret = 0;
45029 strA.resize(digits+3+(isneg?1:0));
45030 //num = Floor(Abs(num));
45031 if ( isneg )
45032 {
45033 strA[pos] = '-';
45034 strA[pos+1] = '0';
45035 strA[pos+2] = 'x';
45036 ret = 3;
45037 }
45038 else
45039 {
45040 strA[pos] = '0';
45041 strA[pos+1] = 'x';
45042 ret = 2;
45043 }
45044
45045 int32_t alphaoffset = 'A' - 0xA;
45046 for(int32_t i = 0; i < digits; ++i)
45047 {
45048 int32_t coeff = ((int32_t)floor((double)(((double)number) / pow((float)0x10, digits - i - 1))) % 0x10);
45049 strA[pos + ret + i] = coeff < 0xA ? coeff + '0' : coeff + alphaoffset;
45050 }
45051 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
45052 {
45053 Z_scripterrlog("Dest string supplied to 'xtoa()' not large enough\n");
45054 set_register(sarg1, 0);
45055 }
45056 //set_register(sarg1, (strcat((char)strA.c_str(), strB.c_str()) * 10000));
45057 else set_register(sarg1, (ret + digits -(isneg?1:0))*10000); //don't count the - sign as a digit
45058 }
45059
45060 void FFScript::do_ilen(const bool v)
45061 {
45062 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
45063 string str;
45064 ArrayH::getString(arrayptr, str);
45065 //zprint("strlen string size is: %d\n", str.length());
45066 set_register(sarg1, (FFCore.ilen((char*)str.c_str()) * 10000));
45067 }
45068
45069 //! Note atoi2 (atoi(str, len) can be accompished with str.resize after getString.
45070 void FFScript::do_atoi(const bool v)
45071 {
45072 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
45073 string str;
45074 ArrayH::getString(arrayptr, str);
45075 set_register(sarg1, (atoi(str.c_str()) * 10000));
45076 }
45077
45078 void FFScript::do_strstr()
45079 {
45080
45081 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
45082 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
45083 string strA;
45084 string strB;
45085 ArrayH::getString(arrayptr_a, strA);
45086 ArrayH::getString(arrayptr_b, strB);
45087 if ( strA.size() < 1 )
45088 {
45089 Z_scripterrlog("String passed to strstr() is too small. Size is: %d \n", strA.size());
45090 set_register(sarg1,-10000);
45091 return;
45092 }
45093 set_register(sarg1, (strA.find(strB) * 10000));
45094 }
45095
45096 void FFScript::do_strcat()
45097 {
45098
45099 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
45100 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
45101 string strA;
45102 string strB;
45103 ArrayH::getString(arrayptr_a, strA);
45104 ArrayH::getString(arrayptr_b, strB);
45105 //char str_c[2048];
45106 //strcpy(str_c, strA.c_str());
45107 string strC = strA + strB;
45108 //zprint("strcat string: %s\n", strC.c_str());
45109 if(ArrayH::setArray(arrayptr_a, strC) == SH::_Overflow)
45110 {
45111 Z_scripterrlog("Dest string supplied to 'strcat()' not large enough\n");
45112 set_register(sarg1, 0);
45113 }
45114 //set_register(sarg1, (strcat((char)strA.c_str(), strB.c_str()) * 10000));
45115 else set_register(sarg1, arrayptr_a); //returns the pointer to the dest
45116 }
45117 void FFScript::do_strspn()
45118 {
45119
45120 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
45121 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
45122 string strA;
45123 string strB;
45124 ArrayH::getString(arrayptr_a, strA);
45125 ArrayH::getString(arrayptr_b, strB);
45126 set_register(sarg1, (strspn(strA.c_str(), strB.c_str()) * 10000));
45127 }
45128
45129 void FFScript::do_strcspn()
45130 {
45131
45132 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
45133 int32_t arrayptr_b = ri->d[rINDEX2]/10000;
45134 string strA;
45135 string strB;
45136 ArrayH::getString(arrayptr_a, strA);
45137 ArrayH::getString(arrayptr_b, strB);
45138 set_register(sarg1, (strcspn(strA.c_str(), strB.c_str()) * 10000));
45139 }
45140
45141 void FFScript::do_strchr()
45142 {
45143
45144 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
45145 char chr_to_find = (ri->d[rINDEX2]/10000);
45146 string strA;
45147 ArrayH::getString(arrayptr_a, strA);
45148 if ( strA.size() < 1 )
45149 {
45150 Z_scripterrlog("String passed to strchr() is too small. Size is: %d \n", strA.size());
45151 set_register(sarg1,-10000);
45152 return;
45153 }
45154
45155 set_register(sarg1,strA.find_first_of(chr_to_find)*10000);
45156 }
45157 void FFScript::do_strrchr()
45158 {
45159 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
45160 char chr_to_find = (ri->d[rINDEX2]/10000);
45161 string strA;
45162 ArrayH::getString(arrayptr_a, strA);
45163 if ( strA.size() < 1 )
45164 {
45165 Z_scripterrlog("String passed to strrchr() is too small. Size is: %d \n", strA.size());
45166 set_register(sarg1,-10000);
45167 return;
45168 }
45169 set_register(sarg1,strA.find_last_of(chr_to_find)*10000);
45170 }
45171
45172 void FFScript::do_remchr2()
45173 {
45174 //Not implemented, remchr not found
45175 //not part of any standard library
45176 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
45177 string strA;
45178 ArrayH::getString(arrayptr_a, strA);
45179 //set_register(sarg1, (remchr(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
45180 }
45181 //Bookmark
45182 void FFScript::do_atoi2()
45183 {
45184 //not implemented; atoi does not take 2 params
45185 int32_t arrayptr_a = ri->d[rINDEX]/10000;
45186 string strA;
45187 ArrayH::getString(arrayptr_a, strA);
45188 //set_register(sarg1, (atoi(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
45189 }
45190 void FFScript::do_ilen2()
45191 {
45192 //not implemented, ilen not found
45193 int32_t arrayptr_a = ri->d[rINDEX]/10000;
45194 string strA;
45195 ArrayH::getString(arrayptr_a, strA);
45196 //set_register(sarg1, (ilen(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
45197 }
45198 void FFScript::do_xlen2()
45199 {
45200 //not implemented, xlen not found
45201 int32_t arrayptr_a = ri->d[rINDEX]/10000;
45202 string strA;
45203 ArrayH::getString(arrayptr_a, strA);
45204 //set_register(sarg1, (xlen(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
45205 }
45206
45207 978 void FFScript::do_itoa()
45208 {
45209 978 int32_t arrayptr_a = get_register(sarg1) / 10000;
45210 978 int32_t number = get_register(sarg2) / 10000;
45211
45212 char buf[16];
45213 978 zc_itoa(number, buf, 10);
45214 978 int32_t ret = ::strlen(buf) * 10000L;
45215
1/2
✓ Branch 0 taken 978 times.
✗ Branch 1 not taken.
978 string strA(buf);
45216
45217
2/4
✓ Branch 0 taken 978 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 978 times.
978 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
45218 {
45219 Z_scripterrlog("Dest string supplied to 'itoa()' not large enough\n");
45220 set_register(sarg1, -1);
45221 }
45222
1/2
✓ Branch 0 taken 978 times.
✗ Branch 1 not taken.
978 else set_register(sarg1, ret); //returns the number of digits used
45223 978 }
45224
45225 void FFScript::do_itoacat()
45226 {
45227
45228 int32_t arrayptr_a = get_register(sarg1) / 10000;
45229 int32_t number = get_register(sarg2) / 10000;
45230
45231 // zprint2("itoacat arrayptr_a is: %d\n",arrayptr_a);
45232 // zprint2("itoacat number is: %d\n",number);
45233
45234 double num = number;
45235 int32_t digits = FFCore.numDigits(number); //int32_t(log10(temp) * 10000.0)
45236 // zprint2("itoacat, digits is: %d\n",digits);
45237 int32_t pos = 0;
45238 int32_t ret = 0;
45239 string strA;
45240 string strB;
45241 strB.resize(digits);
45242 ArrayH::getString(arrayptr_a, strA);
45243 if(num < 0)
45244 {
45245 strB.resize(digits+1);
45246 strB[pos] = '-';
45247 ++ret;
45248 num = -num;
45249 }
45250 else if(num == 0)
45251 {
45252 strB[pos] = '0';
45253 string strC = strA + strB;
45254 if(ArrayH::setArray(arrayptr_a, strC) == SH::_Overflow)
45255 {
45256 Z_scripterrlog("Dest string supplied to 'itoacat()' not large enough\n");
45257 set_register(sarg1, 0);
45258 }
45259 else set_register(sarg1, arrayptr_a); //returns the pointer to the dest
45260 return;
45261 }
45262
45263
45264 for(int32_t i = 0; i < digits; ++i)
45265 strB[pos + ret + i] = ((int32_t)floor((double)(num / pow((float)10, digits - i - 1))) % 10) + '0';
45266
45267 string strC = strA + strB;
45268 if(ArrayH::setArray(arrayptr_a, strC) == SH::_Overflow)
45269 {
45270 Z_scripterrlog("Dest string supplied to 'itoacat()' not large enough\n");
45271 set_register(sarg1, 0);
45272 }
45273 //set_register(sarg1, (strcat((char)strB.c_str(), strB.c_str()) * 10000));
45274 else set_register(sarg1, arrayptr_a); //returns the pointer to the dest
45275 }
45276
45277 /*
45278 void FFScript::do_itoa()
45279 {
45280
45281 int32_t arrayptr_a = ri->d[rINDEX2]/10000;
45282 int32_t value = ri->d[rINDEX]/10000;
45283 char the_string[13];
45284 char* chrptr = NULL;
45285 chrptr = zc_itoa(value, the_string, 10);
45286 //Returns the number of characters used.
45287 if(ArrayH::setArray(arrayptr_a, the_string) == SH::_Overflow)
45288 Z_scripterrlog("Dest string supplied to 'itoa()' not large enough\n");
45289 set_register(sarg1, (FFCore.zc_strlen(the_string)*10000));
45290 }
45291 */
45292
45293 93 void FFScript::do_strcpy(const bool a, const bool b)
45294 {
45295 93 int32_t arrayptr_b = SH::get_arg(sarg1, a) / 10000;
45296 93 int32_t arrayptr_a = SH::get_arg(sarg2, b) / 10000;
45297
45298 93 string strA;
45299
45300
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 ArrayH::getString(arrayptr_a, strA);
45301
45302
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
93 if(ArrayH::setArray(arrayptr_b, strA) == SH::_Overflow)
45303 Z_scripterrlog("Dest string supplied to 'strcpy()' not large enough\n");
45304 93 }
45305 void FFScript::do_arraycpy(const bool a, const bool b)
45306 {
45307 int32_t arrayptr_dest = SH::get_arg(sarg1, a) / 10000;
45308 int32_t arrayptr_src = SH::get_arg(sarg2, b) / 10000;
45309 ArrayH::copyValues(arrayptr_dest, arrayptr_src, ArrayH::getSize(arrayptr_src));
45310 }
45311 void FFScript::do_strlen(const bool v)
45312 {
45313 //zprint("Running: %s\n","strlen()");
45314 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
45315 string str;
45316 ArrayH::getString(arrayptr, str);
45317 //zprint("strlen string size is: %d\n", str.length());
45318 set_register(sarg1, (str.length() * 10000));
45319 }
45320
45321 void FFScript::do_strncmp()
45322 {
45323 int32_t arrayptr_a = ri->d[rINDEX]/10000;
45324 int32_t arrayptr_b = ri->d[rEXP2]/10000;
45325 int32_t len = ri->d[rEXP1]/10000;
45326 string strA;
45327 string strB;
45328 ArrayH::getString(arrayptr_a, strA);
45329 ArrayH::getString(arrayptr_b, strB);
45330 set_register(sarg1, (strncmp(strA.c_str(), strB.c_str(), len) * 10000));
45331 }
45332
45333 void FFScript::do_strnicmp()
45334 {
45335 int32_t arrayptr_a = ri->d[rINDEX]/10000;
45336 int32_t arrayptr_b = ri->d[rEXP2]/10000;
45337 int32_t len = ri->d[rEXP1]/10000;
45338 string strA;
45339 string strB;
45340 ArrayH::getString(arrayptr_a, strA);
45341 ArrayH::getString(arrayptr_b, strB);
45342 set_register(sarg1, (ustrnicmp(strA.c_str(), strB.c_str(), len) * 10000));
45343 }
45344
45345 void FFScript::do_npc_canmove(const bool v)
45346 {
45347 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
45348 int32_t sz = ArrayH::getSize(arrayptr);
45349 //bool can_mv = false;
45350 if(GuyH::loadNPC(ri->guyref, "npc->CanMove()") == SH::_NoError)
45351 {
45352 ArrayManager am(arrayptr);
45353 if(am.invalid()) return;
45354 if ( sz == 1 ) //bool canmove(int32_t ndir): dir only, uses 'step' IIRC
45355 {
45356 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),false)) ? 10000 : 0);
45357 }
45358 else if ( sz == 2 ) //bool canmove(int32_t ndir, int32_t special): I think that this also uses the default 'step'
45359 {
45360 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),(zfix)(am.get(1)/10000), false)) ? 10000 : 0);
45361 }
45362 else if ( sz == 3 ) //bool canmove(int32_t ndir,zfix s,int32_t special) : I'm pretty sure that 'zfix s' is 'step' here.
45363 {
45364 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),(zfix)(am.get(1)/10000),(am.get(2)/10000),false)) ? 10000 : 0);
45365 }
45366 else if ( sz == 7 ) //bool canmove(int32_t ndir,zfix s,int32_t special) : I'm pretty sure that 'zfix s' is 'step' here.
45367 {
45368 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),(zfix)(am.get(1)/10000),(am.get(2)/10000),(am.get(3)/10000),(am.get(4)/10000),(am.get(5)/10000),(am.get(6)/10000),false)) ? 10000 : 0);
45369 }
45370 else
45371 {
45372 Z_scripterrlog("Invalid array size (%d) passed to npc->CanMove(). The array size must be [1], [2], [3], or [7].\n", sz);
45373 //can_mv = false;
45374 set_register(sarg1, 0);
45375 }
45376 }
45377 //set_register(sarg1, ( can_mv ? 10000 : 0));
45378 }
45379
45380 //void do_get_enh_music_filename(const bool v)
45381 void FFScript::get_npcdata_initd_label(const bool v)
45382 {
45383 int32_t init_d_index = SH::get_arg(sarg1, v) / 10000;
45384 int32_t arrayptr = get_register(sarg2) / 10000;
45385
45386 if((unsigned)init_d_index > 7)
45387 {
45388 Z_scripterrlog("Invalid InitD[] index (%d) passed to npcdata->GetInitDLabel().\n", init_d_index);
45389 return;
45390 }
45391
45392 if(ArrayH::setArray(arrayptr, string(guysbuf[ri->npcdataref].initD_label[init_d_index])) == SH::_Overflow)
45393 Z_scripterrlog("Array supplied to 'npcdata->GetInitDLabel()' not large enough\n");
45394 }
45395
45396 /////////////////////
45397 /// MATHS HELPERS ///
45398 /////////////////////
45399
45400 //Returns the log of val to the base 10. Any value <= 0 will return 0.
45401 int32_t FFScript::Log10(double temp)
45402 {
45403 int32_t ret = 0;
45404 if(temp > 0)
45405 ret = int32_t(log10(temp) * 10000.0);
45406 else ret = 0;
45407 return ret;
45408 }
45409
45410 //Returns the number of digits in a given integer.
45411 int32_t FFScript::numDigits(int32_t number)
45412 {
45413 int32_t digits = 0;
45414 while (number)
45415 {
45416 number /= 10;
45417 digits++;
45418 }
45419 return digits;
45420 }
45421
45422 // Returns the natural logarithm of val (to the base e). Any value <= 0 will return 0.
45423 double FFScript::ln(double temp)
45424 {
45425
45426 if(temp > 0)
45427 return (log(temp));
45428 else
45429 {
45430 return 0;
45431 }
45432 }
45433
45434 // Returns the logarithm of x to the given base.
45435 double FFScript::LogToBase(double x, double base)
45436 {
45437 if(x <= 0 || base <= 0) return 0;
45438 return FFCore.ln(x)/FFCore.ln(base);
45439 }
45440
45441 script_command ZASMcommands[NUMCOMMANDS+1]=
45442 {
45443 //name args arg1 arg2 more
45444 { "SETV", 2, 0, 1, 0},
45445 { "SETR", 2, 0, 0, 0},
45446 { "ADDR", 2, 0, 0, 0},
45447 { "ADDV", 2, 0, 1, 0},
45448 { "SUBR", 2, 0, 0, 0},
45449 { "SUBV", 2, 0, 1, 0},
45450 { "MULTR", 2, 0, 0, 0},
45451 { "MULTV", 2, 0, 1, 0},
45452 { "DIVR", 2, 0, 0, 0},
45453 { "DIVV", 2, 0, 1, 0},
45454 { "WAITFRAME", 0, 0, 0, 0},
45455 { "GOTO", 1, 1, 0, 0},
45456 { "CHECKTRIG", 0, 0, 0, 0},
45457 { "WARP", 2, 1, 1, 0},
45458 { "COMPARER", 2, 0, 0, 0},
45459 { "COMPAREV", 2, 0, 1, 0},
45460 { "GOTOTRUE", 1, 1, 0, 0},
45461 { "GOTOFALSE", 1, 1, 0, 0},
45462 { "GOTOLESS", 1, 1, 0, 0},
45463 { "GOTOMORE", 1, 1, 0, 0},
45464 { "LOAD1", 2, 0, 0, 0},
45465 { "LOAD2", 2, 0, 0, 0},
45466 { "SETA1", 2, 0, 0, 0},
45467 { "SETA2", 2, 0, 0, 0},
45468 { "QUIT", 0, 0, 0, 0},
45469 { "SINR", 2, 0, 0, 0},
45470 { "SINV", 2, 0, 1, 0},
45471 { "COSR", 2, 0, 0, 0},
45472 { "COSV", 2, 0, 1, 0},
45473 { "TANR", 2, 0, 0, 0},
45474 { "TANV", 2, 0, 1, 0},
45475 { "MODR", 2, 0, 0, 0},
45476 { "MODV", 2, 0, 1, 0},
45477 { "ABS", 1, 0, 0, 0},
45478 { "MINR", 2, 0, 0, 0},
45479 { "MINV", 2, 0, 1, 0},
45480 { "MAXR", 2, 0, 0, 0},
45481 { "MAXV", 2, 0, 1, 0},
45482 { "RNDR", 2, 0, 0, 0},
45483 { "RNDV", 2, 0, 1, 0},
45484 { "FACTORIAL", 1, 0, 0, 0},
45485 { "POWERR", 2, 0, 0, 0},
45486 { "POWERV", 2, 0, 1, 0},
45487 { "IPOWERR", 2, 0, 0, 0},
45488 { "IPOWERV", 2, 0, 1, 0},
45489 { "ANDR", 2, 0, 0, 0},
45490 { "ANDV", 2, 0, 1, 0},
45491 { "ORR", 2, 0, 0, 0},
45492 { "ORV", 2, 0, 1, 0},
45493 { "XORR", 2, 0, 0, 0},
45494 { "XORV", 2, 0, 1, 0},
45495 { "NANDR", 2, 0, 0, 0},
45496 { "NANDV", 2, 0, 1, 0},
45497 { "NORR", 2, 0, 0, 0},
45498 { "NORV", 2, 0, 1, 0},
45499 { "XNORR", 2, 0, 0, 0},
45500 { "XNORV", 2, 0, 1, 0},
45501 { "NOT", 1, 0, 0, 0},
45502 { "LSHIFTR", 2, 0, 0, 0},
45503 { "LSHIFTV", 2, 0, 1, 0},
45504 { "RSHIFTR", 2, 0, 0, 0},
45505 { "RSHIFTV", 2, 0, 1, 0},
45506 { "TRACER", 1, 0, 0, 0},
45507 { "TRACEV", 1, 1, 0, 0},
45508 { "TRACE3", 0, 0, 0, 0},
45509 { "LOOP", 2, 1, 0, 0},
45510 { "PUSHR", 1, 0, 0, 0},
45511 { "PUSHV", 1, 1, 0, 0},
45512 { "POP", 1, 0, 0, 0},
45513 { "ENQUEUER", 2, 0, 0, 0},
45514 { "ENQUEUEV", 2, 0, 1, 0},
45515 { "DEQUEUE", 1, 0, 0, 0},
45516 { "PLAYSOUNDR", 1, 0, 0, 0},
45517 { "PLAYSOUNDV", 1, 1, 0, 0},
45518 { "LOADLWEAPONR", 1, 0, 0, 0},
45519 { "LOADLWEAPONV", 1, 1, 0, 0},
45520 { "LOADITEMR", 1, 0, 0, 0},
45521 { "LOADITEMV", 1, 1, 0, 0},
45522 { "LOADNPCR", 1, 0, 0, 0},
45523 { "LOADNPCV", 1, 1, 0, 0},
45524 { "CREATELWEAPONR", 1, 0, 0, 0},
45525 { "CREATELWEAPONV", 1, 1, 0, 0},
45526 { "CREATEITEMR", 1, 0, 0, 0},
45527 { "CREATEITEMV", 1, 1, 0, 0},
45528 { "CREATENPCR", 1, 0, 0, 0},
45529 { "CREATENPCV", 1, 1, 0, 0},
45530 { "LOADI", 2, 0, 0, 0},
45531 { "STOREI", 2, 0, 0, 0},
45532 { "GOTOR", 1, 0, 0, 0},
45533 { "SQROOTV", 2, 0, 1, 0},
45534 { "SQROOTR", 2, 0, 0, 0},
45535 { "CREATEEWEAPONR", 1, 0, 0, 0},
45536 { "CREATEEWEAPONV", 1, 1, 0, 0},
45537 { "PITWARP", 2, 1, 1, 0},
45538 { "WARPR", 2, 0, 0, 0},
45539 { "PITWARPR", 2, 0, 0, 0},
45540 { "CLEARSPRITESR", 1, 0, 0, 0},
45541 { "CLEARSPRITESV", 1, 1, 0, 0},
45542 { "RECT", 0, 0, 0, 0},
45543 { "CIRCLE", 0, 0, 0, 0},
45544 { "ARC", 0, 0, 0, 0},
45545 { "ELLIPSE", 0, 0, 0, 0},
45546 { "LINE", 0, 0, 0, 0},
45547 { "PUTPIXEL", 0, 0, 0, 0},
45548 { "DRAWTILE", 0, 0, 0, 0},
45549 { "DRAWCOMBO", 0, 0, 0, 0},
45550 { "ELLIPSE2", 0, 0, 0, 0},
45551 { "SPLINE", 0, 0, 0, 0},
45552 { "FLOODFILL", 0, 0, 0, 0},
45553 { "COMPOUNDR", 1, 0, 0, 0},
45554 { "COMPOUNDV", 1, 1, 0, 0},
45555 { "MSGSTRR", 1, 0, 0, 0},
45556 { "MSGSTRV", 1, 1, 0, 0},
45557 { "ISVALIDITEM", 1, 0, 0, 0},
45558 { "ISVALIDNPC", 1, 0, 0, 0},
45559 { "PLAYMIDIR", 1, 0, 0, 0},
45560 { "PLAYMIDIV", 1, 1, 0, 0},
45561 { "COPYTILEVV", 2, 1, 1, 0},
45562 { "COPYTILEVR", 2, 1, 0, 0},
45563 { "COPYTILERV", 2, 0, 1, 0},
45564 { "COPYTILERR", 2, 0, 0, 0},
45565 { "SWAPTILEVV", 2, 1, 1, 0},
45566 { "SWAPTILEVR", 2, 1, 0, 0},
45567 { "SWAPTILERV", 2, 0, 1, 0},
45568 { "SWAPTILERR", 2, 0, 0, 0},
45569 { "CLEARTILEV", 1, 1, 0, 0},
45570 { "CLEARTILER", 1, 0, 0, 0},
45571 { "OVERLAYTILEVV", 2, 1, 1, 0},
45572 { "OVERLAYTILEVR", 2, 1, 0, 0},
45573 { "OVERLAYTILERV", 2, 0, 1, 0},
45574 { "OVERLAYTILERR", 2, 0, 0, 0},
45575 { "FLIPROTTILEVV", 2, 1, 1, 0},
45576 { "FLIPROTTILEVR", 2, 1, 0, 0},
45577 { "FLIPROTTILERV", 2, 0, 1, 0},
45578 { "FLIPROTTILERR", 2, 0, 0, 0},
45579 { "GETTILEPIXEL", 0, 0, 0, 0},
45580 { "RESRVD_OP_MOOSH_EX_01", 1, 0, 0, 0},
45581 { "SETTILEPIXEL", 0, 0, 0, 0},
45582 { "RESRVD_OP_MOOSH_EX_02", 1, 0, 0, 0},
45583 { "SHIFTTILEVV", 2, 1, 1, 0},
45584 { "SHIFTTILEVR", 2, 1, 0, 0},
45585 { "SHIFTTILERV", 2, 0, 1, 0},
45586 { "SHIFTTILERR", 2, 0, 0, 0},
45587 { "ISVALIDLWPN", 1, 0, 0, 0},
45588 { "ISVALIDEWPN", 1, 0, 0, 0},
45589 { "LOADEWEAPONR", 1, 0, 0, 0},
45590 { "LOADEWEAPONV", 1, 1, 0, 0},
45591 { "ALLOCATEMEMR", 2, 0, 0, 0},
45592 { "ALLOCATEMEMV", 2, 0, 1, 0},
45593 { "ALLOCATEGMEMV", 2, 0, 1, 0},
45594 { "DEALLOCATEMEMR", 1, 0, 0, 0},
45595 { "DEALLOCATEMEMV", 1, 1, 0, 0},
45596 { "WAITDRAW", 0, 0, 0, 0},
45597 { "ARCTANR", 1, 0, 0, 0},
45598 { "LWPNUSESPRITER", 1, 0, 0, 0},
45599 { "LWPNUSESPRITEV", 1, 1, 0, 0},
45600 { "EWPNUSESPRITER", 1, 0, 0, 0},
45601 { "EWPNUSESPRITEV", 1, 1, 0, 0},
45602 { "LOADITEMDATAR", 1, 0, 0, 0},
45603 { "LOADITEMDATAV", 1, 1, 0, 0},
45604 { "BITNOT", 1, 0, 0, 0},
45605 { "LOG10", 1, 0, 0, 0},
45606 { "LOGE", 1, 0, 0, 0},
45607 { "ISSOLID", 1, 0, 0, 0},
45608 { "LAYERSCREEN", 2, 0, 0, 0},
45609 { "LAYERMAP", 2, 0, 0, 0},
45610 { "TRACE2R", 1, 0, 0, 0},
45611 { "TRACE2V", 1, 1, 0, 0},
45612 { "TRACE4", 0, 0, 0, 0},
45613 { "TRACE5", 0, 0, 0, 0},
45614 { "SECRETS", 0, 0, 0, 0},
45615 { "DRAWCHAR", 0, 0, 0, 0},
45616 { "GETSCREENFLAGS", 1, 0, 0, 0},
45617 { "QUAD", 0, 0, 0, 0},
45618 { "TRIANGLE", 0, 0, 0, 0},
45619 { "ARCSINR", 2, 0, 0, 0},
45620 { "ARCSINV", 2, 1, 0, 0},
45621 { "ARCCOSR", 2, 0, 0, 0},
45622 { "ARCCOSV", 2, 1, 0, 0},
45623 { "GAMEEND", 0, 0, 0, 0},
45624 { "DRAWINT", 0, 0, 0, 0},
45625 { "SETTRUE", 1, 0, 0, 0},
45626 { "SETFALSE", 1, 0, 0, 0},
45627 { "SETMORE", 1, 0, 0, 0},
45628 { "SETLESS", 1, 0, 0, 0},
45629 { "FASTTILE", 0, 0, 0, 0},
45630 { "FASTCOMBO", 0, 0, 0, 0},
45631 { "DRAWSTRING", 0, 0, 0, 0},
45632 { "SETSIDEWARP", 0, 0, 0, 0},
45633 { "SAVE", 0, 0, 0, 0},
45634 { "TRACE6", 0, 0, 0, 0},
45635 { "DEPRECATED", 1, 0, 0, 0},
45636 { "QUAD3D", 0, 0, 0, 0},
45637 { "TRIANGLE3D", 0, 0, 0, 0},
45638 { "SETCOLORB", 0, 0, 0, 0},
45639 { "SETDEPTHB", 0, 0, 0, 0},
45640 { "GETCOLORB", 0, 0, 0, 0},
45641 { "GETDEPTHB", 0, 0, 0, 0},
45642 { "COMBOTILE", 2, 0, 0, 0},
45643 { "SETTILEWARP", 0, 0, 0, 0},
45644 { "GETSCREENEFLAGS", 1, 0, 0, 0},
45645 { "GETSAVENAME", 1, 0, 0, 0},
45646 { "ARRAYSIZE", 1, 0, 0, 0},
45647 { "ITEMNAME", 1, 0, 0, 0},
45648 { "SETSAVENAME", 1, 0, 0, 0},
45649 { "NPCNAME", 1, 0, 0, 0},
45650 { "GETMESSAGE", 2, 0, 0, 0},
45651 { "GETDMAPNAME", 2, 0, 0, 0},
45652 { "GETDMAPTITLE", 2, 0, 0, 0},
45653 { "GETDMAPINTRO", 2, 0, 0, 0},
45654 { "ALLOCATEGMEMR", 2, 0, 0, 0},
45655 { "DRAWBITMAP", 0, 0, 0, 0},
45656 { "SETRENDERTARGET", 0, 0, 0, 0},
45657 { "PLAYENHMUSIC", 2, 0, 0, 0},
45658 { "GETMUSICFILE", 2, 0, 0, 0},
45659 { "GETMUSICTRACK", 1, 0, 0, 0},
45660 { "SETDMAPENHMUSIC", 0, 0, 0, 0},
45661 { "DRAWLAYER", 0, 0, 0, 0},
45662 { "DRAWSCREEN", 0, 0, 0, 0},
45663 { "BREAKSHIELD", 1, 0, 0, 0},
45664 { "SAVESCREEN", 1, 0, 0, 0},
45665 { "SAVEQUITSCREEN", 0, 0, 0, 0},
45666 { "SELECTAWPNR", 1, 0, 0, 0},
45667 { "SELECTAWPNV", 1, 1, 0, 0},
45668 { "SELECTBWPNR", 1, 0, 0, 0},
45669 { "SELECTBWPNV", 1, 1, 0, 0},
45670 { "GETSIDEWARPDMAP", 1, 0, 0, 0},
45671 { "GETSIDEWARPSCR", 1, 0, 0, 0},
45672 { "GETSIDEWARPTYPE", 1, 0, 0, 0},
45673 { "GETTILEWARPDMAP", 1, 0, 0, 0},
45674 { "GETTILEWARPSCR", 1, 0, 0, 0},
45675 { "GETTILEWARPTYPE", 1, 0, 0, 0},
45676 { "GETFFCSCRIPT", 1, 0, 0, 0},
45677 { "BITMAPEXR", 0, 0, 0, 0},
45678 { "__RESERVED_FOR_QUAD2R", 0, 0, 0, 0},
45679 { "WAVYIN", 0, 0, 0, 0},
45680 { "WAVYOUT", 0, 0, 0, 0},
45681 { "ZAPIN", 0, 0, 0, 0},
45682 { "ZAPOUT", 0, 0, 0, 0},
45683 { "OPENWIPE", 0, 0, 0, 0},
45684 { "FREE0x00F1", 0, 0, 0, 0 },
45685 { "FREE0x00F2", 0, 0, 0, 0},
45686 { "FREE0x00F3", 0, 0, 0,0},
45687 { "SETMESSAGE", 2, 0, 0, 0},
45688 { "SETDMAPNAME", 2, 0, 0, 0},
45689 { "SETDMAPTITLE", 2, 0, 0, 0},
45690 { "SETDMAPINTRO", 2, 0, 0, 0},
45691 { "GREYSCALEON", 0, 0, 0, 0},
45692 { "GREYSCALEOFF", 0, 0, 0, 0},
45693 { "ENDSOUNDR", 1, 0, 0, 0},
45694 { "ENDSOUNDV", 1, 1, 0, 0},
45695 { "PAUSESOUNDR", 1, 0, 0, 0},
45696 { "PAUSESOUNDV", 1, 1, 0, 0},
45697 { "RESUMESOUNDR", 1, 0, 0, 0},
45698 { "RESUMESOUNDV", 1, 1, 0, 0},
45699 { "PAUSEMUSIC", 0, 0, 0, 0},
45700 { "RESUMEMUSIC", 0, 0, 0, 0},
45701 { "LWPNARRPTR", 1, 0, 0, 0},
45702 { "EWPNARRPTR", 1, 0, 0, 0},
45703 { "EWPNARRPTR", 1, 0, 0, 0},
45704 { "IDATAARRPTR", 1, 0, 0, 0},
45705 { "FFCARRPTR", 1, 0, 0, 0},
45706 { "BOOLARRPTR", 1, 0, 0, 0},
45707 { "BOOLARRPTR", 1, 0, 0, 0},
45708 { "LWPNARRPTR2", 1, 0, 0, 0},
45709 { "EWPNARRPTR2", 1, 0, 0, 0},
45710 { "ITEMARRPTR2", 1, 0, 0, 0},
45711 { "IDATAARRPTR2", 1, 0, 0, 0},
45712 { "FFCARRPTR2", 1, 0, 0, 0},
45713 { "BOOLARRPTR2", 1, 0, 0, 0},
45714 { "NPCARRPTR2", 1, 0, 0, 0},
45715 { "ARRAYSIZEB", 1, 0, 0, 0},
45716 { "ARRAYSIZEF", 1, 0, 0, 0},
45717 { "ARRAYSIZEN", 1, 0, 0, 0},
45718 { "ARRAYSIZEL", 1, 0, 0, 0},
45719 { "ARRAYSIZEE", 1, 0, 0, 0},
45720 { "ARRAYSIZEI", 1, 0, 0, 0},
45721 { "ARRAYSIZEID", 1, 0, 0, 0},
45722 { "POLYGONR", 0, 0, 0, 0},
45723 { "__RESERVED_FOR_POLYGON3DR", 0, 0, 0, 0},
45724 { "__RESERVED_FOR_SETRENDERSOURCE", 0, 0, 0, 0},
45725 { "LINESARRAY", 0, 0, 0, 0},
45726 { "PIXELARRAYR", 0, 0, 0, 0},
45727 { "TILEARRAYR", 0, 0, 0, 0},
45728 { "COMBOARRAYR", 0, 0, 0, 0},
45729 { "RES0000", 0, 0, 0, 0},
45730 { "RES0001", 0, 0, 0, 0},
45731 { "RES0002", 0, 0, 0, 0},
45732 { "RES0003", 0, 0, 0, 0},
45733 { "RES0004", 0, 0, 0, 0},
45734 { "RES0005", 0, 0, 0, 0},
45735 { "RES0006", 0, 0, 0, 0},
45736 { "RES0007", 0, 0, 0, 0},
45737 { "RES0008", 0, 0, 0, 0},
45738 { "RES0009", 0, 0, 0, 0},
45739 { "RES000A", 0, 0, 0, 0},
45740 { "RES000B", 0, 0, 0, 0},
45741 { "RES000C", 0, 0, 0, 0},
45742 { "RES000D", 0, 0, 0, 0},
45743 { "RES000E", 0, 0, 0, 0},
45744 { "RES000F", 0, 0, 0, 0},
45745 { "__RESERVED_FOR_CREATELWPN2VV", 2, 1, 1, 0},
45746 { "__RESERVED_FOR_CREATELWPN2VR", 2, 1, 0, 0},
45747 { "__RESERVED_FOR_CREATELWPN2RV", 2, 0, 1, 0},
45748 { "__RESERVED_FOR_CREATELWPN2RR", 2, 0, 0, 0},
45749 { "GETSCREENDOOR", 1, 0, 0, 0},
45750 { "GETSCREENENEMY", 1, 0, 0, 0},
45751 { "PAUSESFX", 1, 0, 0, 0},
45752 { "RESUMESFX", 1, 0, 0, 0},
45753 { "CONTINUESFX", 1, 0, 0, 0},
45754 { "ADJUSTSFX", 0, 0, 0, 0},
45755 { "GETITEMSCRIPT", 1, 0, 0, 0},
45756 { "GETSCREENLAYOP", 1, 0, 0, 0},
45757 { "GETSCREENSECCMB", 1, 0, 0, 0},
45758 { "GETSCREENSECCST", 1, 0, 0, 0},
45759 { "GETSCREENSECFLG", 1, 0, 0, 0},
45760 { "GETSCREENLAYMAP", 1, 0, 0, 0},
45761 { "GETSCREENLAYSCR", 1, 0, 0, 0},
45762 { "GETSCREENPATH", 1, 0, 0, 0},
45763 { "GETSCREENWARPRX", 1, 0, 0, 0},
45764 { "GETSCREENWARPRY", 1, 0, 0, 0},
45765 { "TRIGGERSECRETR", 1, 0, 0, 0},
45766 { "TRIGGERSECRETV", 1, 1, 0, 0},
45767 { "NIL_UNUSED_1", 1, 0, 0, 0},
45768 { "NIL_UNUSED_2", 1, 1, 0, 0},
45769 //NPCData
45770 //one input, one return
45771 { "GETNPCDATAFLAGS", 2, 0, 0, 0},
45772 { "GETNPCDATAFLAGS2", 2, 0, 0, 0},
45773 { "GETNPCDATAWIDTH", 2, 0, 0, 0},
45774 { "GETNPCDATAHEIGHT", 2, 0, 0, 0},
45775 { "GETNPCDATASTILE", 2, 0, 0, 0},
45776 { "GETNPCDATASWIDTH", 2, 0, 0, 0},
45777 { "GETNPCDATASHEIGHT", 2, 0, 0, 0},
45778 { "GETNPCDATAETILE", 2, 0, 0, 0},
45779 { "GETNPCDATAEWIDTH", 2, 0, 0, 0},
45780 { "GETNPCDATAHP", 2, 0, 0, 0},
45781 { "GETNPCDATAFAMILY", 2, 0, 0, 0},
45782 { "GETNPCDATACSET", 2, 0, 0, 0},
45783 { "GETNPCDATAANIM", 2, 0, 0, 0},
45784 { "GETNPCDATAEANIM", 2, 0, 0, 0},
45785 { "GETNPCDATAFRAMERATE", 2, 0, 0, 0},
45786 { "GETNPCDATAEFRAMERATE", 2, 0, 0, 0},
45787 { "GETNPCDATATOUCHDMG", 2, 0, 0, 0},
45788 { "GETNPCDATAWPNDAMAGE", 2, 0, 0, 0},
45789 { "GETNPCDATAWEAPON", 2, 0, 0, 0},
45790 { "GETNPCDATARANDOM", 2, 0, 0, 0},
45791 { "GETNPCDATAHALT", 2, 0, 0, 0},
45792 { "GETNPCDATASTEP", 2, 0, 0, 0},
45793 { "GETNPCDATAHOMING", 2, 0, 0, 0},
45794 { "GETNPCDATAHUNGER", 2, 0, 0, 0},
45795 { "GETNPCDATADROPSET", 2, 0, 0, 0},
45796 { "GETNPCDATABGSFX", 2, 0, 0, 0},
45797 { "GETNPCDATADEATHSFX", 2, 0, 0, 0},
45798 { "GETNPCDATAXOFS", 2, 0, 0, 0},
45799 { "GETNPCDATAYOFS", 2, 0, 0, 0},
45800 { "GETNPCDATAZOFS", 2, 0, 0, 0},
45801 { "GETNPCDATAHXOFS", 2, 0, 0, 0},
45802 { "GETNPCDATAHYOFS", 2, 0, 0, 0},
45803 { "GETNPCDATAHITWIDTH", 2, 0, 0, 0},
45804 { "GETNPCDATAHITHEIGHT", 2, 0, 0, 0},
45805 { "GETNPCDATAHITZ", 2, 0, 0, 0},
45806 { "GETNPCDATATILEWIDTH", 2, 0, 0, 0},
45807 { "GETNPCDATATILEHEIGHT", 2, 0, 0, 0},
45808 { "GETNPCDATAWPNSPRITE", 2, 0, 0, 0},
45809 //two inputs one return
45810 { "GETNPCDATASCRIPTDEF", 1, 0, 0, 0},
45811 { "GETNPCDATADEFENSE", 1, 0, 0, 0},
45812 { "GETNPCDATASIZEFLAG", 1, 0, 0, 0},
45813 { "GETNPCDATAATTRIBUTE", 1, 0, 0, 0},
45814 //two inputs no return
45815 { "SETNPCDATAFLAGS", 2, 0, 0, 0},
45816 { "SETNPCDATAFLAGS2", 2, 0, 0, 0},
45817 { "SETNPCDATAWIDTH", 2, 0, 0, 0},
45818 { "SETNPCDATAHEIGHT", 2, 0, 0, 0},
45819 { "SETNPCDATASTILE", 2, 0, 0, 0},
45820 { "SETNPCDATASWIDTH", 2, 0, 0, 0},
45821 { "SETNPCDATASHEIGHT", 2, 0, 0, 0},
45822 { "SETNPCDATAETILE", 2, 0, 0, 0},
45823 { "SETNPCDATAEWIDTH", 2, 0, 0, 0},
45824 { "SETNPCDATAHP", 2, 0, 0, 0},
45825 { "SETNPCDATAFAMILY", 2, 0, 0, 0},
45826 { "SETNPCDATACSET", 2, 0, 0, 0},
45827 { "SETNPCDATAANIM", 2, 0, 0, 0},
45828 { "SETNPCDATAEANIM", 2, 0, 0, 0},
45829 { "SETNPCDATAFRAMERATE", 2, 0, 0, 0},
45830 { "SETNPCDATAEFRAMERATE", 2, 0, 0, 0},
45831 { "SETNPCDATATOUCHDMG", 2, 0, 0, 0},
45832 { "SETNPCDATAWPNDAMAGE", 2, 0, 0, 0},
45833 { "SETNPCDATAWEAPON", 2, 0, 0, 0},
45834 { "SETNPCDATARANDOM", 2, 0, 0, 0},
45835 { "SETNPCDATAHALT", 2, 0, 0, 0},
45836 { "SETNPCDATASTEP", 2, 0, 0, 0},
45837 { "SETNPCDATAHOMING", 2, 0, 0, 0},
45838 { "SETNPCDATAHUNGER", 2, 0, 0, 0},
45839 { "SETNPCDATADROPSET", 2, 0, 0, 0},
45840 { "SETNPCDATABGSFX", 2, 0, 0, 0},
45841 { "SETNPCDATADEATHSFX", 2, 0, 0, 0},
45842 { "SETNPCDATAXOFS", 2, 0, 0, 0},
45843 { "SETNPCDATAYOFS", 2, 0, 0, 0},
45844 { "SETNPCDATAZOFS", 2, 0, 0, 0},
45845 { "SETNPCDATAHXOFS", 2, 0, 0, 0},
45846 { "SETNPCDATAHYOFS", 2, 0, 0, 0},
45847 { "SETNPCDATAHITWIDTH", 2, 0, 0, 0},
45848 { "SETNPCDATAHITHEIGHT", 2, 0, 0, 0},
45849 { "SETNPCDATAHITZ", 2, 0, 0, 0},
45850 { "SETNPCDATATILEWIDTH", 2, 0, 0, 0},
45851 { "SETNPCDATATILEHEIGHT", 2, 0, 0, 0},
45852 { "SETNPCDATAWPNSPRITE", 2, 0, 0, 0},
45853 { "SETNPCDATAHITSFX", 2, 0, 0, 0},
45854 { "GETNPCDATAHITSFX", 2, 0, 0, 0},
45855 //Combodata, one input no return
45856 { "GCDBLOCKENEM", 2, 0, 0, 0},
45857 { "GCDBLOCKHOLE", 2, 0, 0, 0},
45858 { "GCDBLOCKTRIG", 2, 0, 0, 0},
45859 { "GCDCONVEYSPDX", 2, 0, 0, 0},
45860 { "GCDCONVEYSPDY", 2, 0, 0, 0},
45861 { "GCDCREATEENEM", 2, 0, 0, 0},
45862 { "GCDCREATEENEMWH", 2, 0, 0, 0},
45863 { "GCDCREATEENEMCH", 2, 0, 0, 0},
45864 { "GCDDIRCHTYPE", 2, 0, 0, 0},
45865 { "GCDDISTCHTILES", 2, 0, 0, 0},
45866 { "GCDDIVEITEM", 2, 0, 0, 0},
45867 { "GCDDOCK", 2, 0, 0, 0},
45868 { "GCDFAIRY", 2, 0, 0, 0},
45869 { "GCDFFCOMBOATTRIB", 2, 0, 0, 0},
45870 { "GCDFOOTDECOTILE", 2, 0, 0, 0},
45871 { "GCDFOOTDECOTYPE", 2, 0, 0, 0},
45872 { "GCDHOOKSHOTGRAB", 2, 0, 0, 0},
45873 { "GCDLADDERPASS", 2, 0, 0, 0},
45874 { "GCDLOCKBLOCKTYPE", 2, 0, 0, 0},
45875 { "GCDLOCKBLOCKCHANGE", 2, 0, 0, 0},
45876 { "GCDMAGICMIRRORTYPE", 2, 0, 0, 0},
45877 { "GCDMODIFYHPAMOUNT", 2, 0, 0, 0},
45878 { "GCDMODIFYHPDELAY", 2, 0, 0, 0},
45879 { "GCDMODIFYHPTYPE", 2, 0, 0, 0},
45880 { "GCDMODIFYMPAMOUNT", 2, 0, 0, 0},
45881 { "GCDMODIFYMPDELAY", 2, 0, 0, 0},
45882 { "GCDMODIFYMPTYPE", 2, 0, 0, 0},
45883 { "GCDNOPUSHBLOCKS", 2, 0, 0, 0},
45884 { "GCDOVERHEAD", 2, 0, 0, 0},
45885 { "GCDPLACEENEMY", 2, 0, 0, 0},
45886 { "GCDPUSHDIR", 2, 0, 0, 0},
45887 { "GCDPUSHWEIGHT", 2, 0, 0, 0},
45888 { "GCDPUSHWAIT", 2, 0, 0, 0},
45889 { "GCDPUSHED", 2, 0, 0, 0},
45890 { "GCDRAFT", 2, 0, 0, 0},
45891 { "GCDRESETROOM", 2, 0, 0, 0},
45892 { "GCDSAVEPOINT", 2, 0, 0, 0},
45893 { "GCDSCREENFREEZE", 2, 0, 0, 0},
45894 { "GCDSECRETCOMBO", 2, 0, 0, 0},
45895 { "GCDSINGULAR", 2, 0, 0, 0},
45896 { "GCDSLOWMOVE", 2, 0, 0, 0},
45897 { "GCDSTATUE", 2, 0, 0, 0},
45898 { "GCDSTEPTYPE", 2, 0, 0, 0},
45899 { "GCDSTEPCHANGETO", 2, 0, 0, 0},
45900 { "GCDSTRIKEREMNANTS", 2, 0, 0, 0},
45901 { "GCDSTRIKEREMNANTSTYPE", 2, 0, 0, 0},
45902 { "GCDSTRIKECHANGE", 2, 0, 0, 0},
45903 { "GCDSTRIKECHANGEITEM", 2, 0, 0, 0},
45904 { "GCDTOUCHITEM", 2, 0, 0, 0},
45905 { "GCDTOUCHSTAIRS", 2, 0, 0, 0},
45906 { "GCDTRIGGERTYPE", 2, 0, 0, 0},
45907 { "GCDTRIGGERSENS", 2, 0, 0, 0},
45908 { "GCDWARPTYPE", 2, 0, 0, 0},
45909 { "GCDWARPSENS", 2, 0, 0, 0},
45910 { "GCDWARPDIRECT", 2, 0, 0, 0},
45911 { "GCDWARPLOCATION", 2, 0, 0, 0},
45912 { "GCDWATER", 2, 0, 0, 0},
45913 { "GCDWHISTLE", 2, 0, 0, 0},
45914 { "GCDWINGAME", 2, 0, 0, 0},
45915 { "GCDBLOCKWEAPLVL", 2, 0, 0, 0},
45916 { "GCDTILE", 2, 0, 0, 0},
45917 { "GCDFLIP", 2, 0, 0, 0},
45918 { "GCDWALK", 2, 0, 0, 0},
45919 { "GCDTYPE", 2, 0, 0, 0},
45920 { "GCDCSETS", 2, 0, 0, 0},
45921 { "GCDFOO", 2, 0, 0, 0},
45922 { "GCDFRAMES", 2, 0, 0, 0},
45923 { "GCDSPEED", 2, 0, 0, 0},
45924 { "GCDNEXTCOMBO", 2, 0, 0, 0},
45925 { "GCDNEXTCSET", 2, 0, 0, 0},
45926 { "GCDFLAG", 2, 0, 0, 0},
45927 { "GCDSKIPANIM", 2, 0, 0, 0},
45928 { "GCDNEXTTIMER", 2, 0, 0, 0},
45929 { "GCDSKIPANIMY", 2, 0, 0, 0},
45930 { "GCDANIMFLAGS", 2, 0, 0, 0},
45931 //combodata two input, one return
45932 { "GCDBLOCKWEAPON", 1, 0, 0, 0},
45933 { "GCDEXPANSION", 1, 0, 0, 0},
45934 { "GCDSTRIKEWEAPONS", 1, 0, 0, 0},
45935 //combodata two input, one return
45936 { "SCDBLOCKENEM", 2, 0, 0, 0},
45937 { "SCDBLOCKHOLE", 2, 0, 0, 0},
45938 { "SCDBLOCKTRIG", 2, 0, 0, 0},
45939 { "SCDCONVEYSPDX", 2, 0, 0, 0},
45940 { "SCDCONVEYSPDY", 2, 0, 0, 0},
45941 { "SCDCREATEENEM", 2, 0, 0, 0},
45942 { "SCDCREATEENEMWH", 2, 0, 0, 0},
45943 { "SCDCREATEENEMCH", 2, 0, 0, 0},
45944 { "SCDDIRCHTYPE", 2, 0, 0, 0},
45945 { "SCDDISTCHTILES", 2, 0, 0, 0},
45946 { "SCDDIVEITEM", 2, 0, 0, 0},
45947 { "SCDDOCK", 2, 0, 0, 0},
45948 { "SCDFAIRY", 2, 0, 0, 0},
45949 { "SCDFFCOMBOATTRIB", 2, 0, 0, 0},
45950 { "SCDFOOTDECOTILE", 2, 0, 0, 0},
45951 { "SCDFOOTDECOTYPE", 2, 0, 0, 0},
45952 { "SCDHOOKSHOTGRAB", 2, 0, 0, 0},
45953 { "SCDLADDERPASS", 2, 0, 0, 0},
45954 { "SCDLOCKBLOCKTYPE", 2, 0, 0, 0},
45955 { "SCDLOCKBLOCKCHANGE", 2, 0, 0, 0},
45956 { "SCDMAGICMIRRORTYPE", 2, 0, 0, 0},
45957 { "SCDMODIFYHPAMOUNT", 2, 0, 0, 0},
45958 { "SCDMODIFYHPDELAY", 2, 0, 0, 0},
45959 { "SCDMODIFYHPTYPE", 2, 0, 0, 0},
45960 { "SCDMODIFYMPAMOUNT", 2, 0, 0, 0},
45961 { "SCDMODIFYMPDELAY", 2, 0, 0, 0},
45962 { "SCDMODIFYMPTYPE", 2, 0, 0, 0},
45963 { "SCDNOPUSHBLOCKS", 2, 0, 0, 0},
45964 { "SCDOVERHEAD", 2, 0, 0, 0},
45965 { "SCDPLACEENEMY", 2, 0, 0, 0},
45966 { "SCDPUSHDIR", 2, 0, 0, 0},
45967 { "SCDPUSHWEIGHT", 2, 0, 0, 0},
45968 { "SCDPUSHWAIT", 2, 0, 0, 0},
45969 { "SCDPUSHED", 2, 0, 0, 0},
45970 { "SCDRAFT", 2, 0, 0, 0},
45971 { "SCDRESETROOM", 2, 0, 0, 0},
45972 { "SCDSAVEPOINT", 2, 0, 0, 0},
45973 { "SCDSCREENFREEZE", 2, 0, 0, 0},
45974 { "SCDSECRETCOMBO", 2, 0, 0, 0},
45975 { "SCDSINGULAR", 2, 0, 0, 0},
45976 { "SCDSLOWMOVE", 2, 0, 0, 0},
45977 { "SCDSTATUE", 2, 0, 0, 0},
45978 { "SCDSTEPTYPE", 2, 0, 0, 0},
45979 { "SCDSTEPCHANGETO", 2, 0, 0, 0},
45980 { "SCDSTRIKEREMNANTS", 2, 0, 0, 0},
45981 { "SCDSTRIKEREMNANTSTYPE", 2, 0, 0, 0},
45982 { "SCDSTRIKECHANGE", 2, 0, 0, 0},
45983 { "SCDSTRIKECHANGEITEM", 2, 0, 0, 0},
45984 { "SCDTOUCHITEM", 2, 0, 0, 0},
45985 { "SCDTOUCHSTAIRS", 2, 0, 0, 0},
45986 { "SCDTRIGGERTYPE", 2, 0, 0, 0},
45987 { "SCDTRIGGERSENS", 2, 0, 0, 0},
45988 { "SCDWARPTYPE", 2, 0, 0, 0},
45989 { "SCDWARPSENS", 2, 0, 0, 0},
45990 { "SCDWARPDIRECT", 2, 0, 0, 0},
45991 { "SCDWARPLOCATION", 2, 0, 0, 0},
45992 { "SCDWATER", 2, 0, 0, 0},
45993 { "SCDWHISTLE", 2, 0, 0, 0},
45994 { "SCDWINGAME", 2, 0, 0, 0},
45995 { "SCDBLOCKWEAPLVL", 2, 0, 0, 0},
45996 { "SCDTILE", 2, 0, 0, 0},
45997 { "SCDFLIP", 2, 0, 0, 0},
45998 { "SCDWALK", 2, 0, 0, 0},
45999 { "SCDTYPE", 2, 0, 0, 0},
46000 { "SCDCSETS", 2, 0, 0, 0},
46001 { "SCDFOO", 2, 0, 0, 0},
46002 { "SCDFRAMES", 2, 0, 0, 0},
46003 { "SCDSPEED", 2, 0, 0, 0},
46004 { "SCDNEXTCOMBO", 2, 0, 0, 0},
46005 { "SCDNEXTCSET", 2, 0, 0, 0},
46006 { "SCDFLAG", 2, 0, 0, 0},
46007 { "SCDSKIPANIM", 2, 0, 0, 0},
46008 { "SCDNEXTTIMER", 2, 0, 0, 0},
46009 { "SCDSKIPANIMY", 2, 0, 0, 0},
46010 { "SCDANIMFLAGS", 2, 0, 0, 0},
46011 { "GETNPCDATATILE", 2, 0, 0, 0},
46012 { "GETNPCDATAEHEIGHT", 2, 0, 0, 0},
46013 { "SETNPCDATATILE", 2, 0, 0, 0},
46014 { "SETNPCDATAEHEIGHT", 2, 0, 0, 0},
46015 { "GETSPRITEDATASTRING", 2, 0, 0, 0},
46016 //SpriteData
46017 { "GETSPRITEDATATILE", 2, 0, 0, 0},
46018 { "GETSPRITEDATAMISC", 2, 0, 0, 0},
46019 { "GETSPRITEDATACGETS", 2, 0, 0, 0},
46020 { "GETSPRITEDATAFRAMES", 2, 0, 0, 0},
46021 { "GETSPRITEDATASPEED", 2, 0, 0, 0},
46022 { "GETSPRITEDATATYPE", 2, 0, 0, 0},
46023 { "SETSPRITEDATASTRING", 2, 0, 0, 0},
46024 { "SETSPRITEDATATILE", 2, 0, 0, 0},
46025 { "SETSPRITEDATAMISC", 2, 0, 0, 0},
46026 { "SETSPRITEDATACSETS", 2, 0, 0, 0},
46027 { "SETSPRITEDATAFRAMES", 2, 0, 0, 0},
46028 { "SETSPRITEDATASPEED", 2, 0, 0, 0},
46029 { "SETSPRITEDATATYPE", 2, 0, 0, 0},
46030 //Game->SetContinueScreenSetting
46031 { "SETCONTINUESCREEN", 2, 0, 0, 0},
46032 //Game->SetContinueScreenString
46033 { "SETCONTINUESTRING", 2, 0, 0, 0},
46034
46035 { "LOADNPCDATAR", 1, 0, 0, 0},
46036 { "LOADNPCDATAV", 1, 1, 0, 0},
46037
46038 { "LOADCOMBODATAR", 1, 0, 0, 0},
46039 { "LOADCOMBODATAV", 1, 1, 0, 0},
46040
46041 { "LOADMAPDATAR", 1, 0, 0, 0},
46042 { "LOADMAPDATAV", 1, 1, 0, 0},
46043
46044 { "LOADSPRITEDATAR", 1, 0, 0, 0},
46045 { "LOADSPRITEDATAV", 1, 1, 0, 0},
46046
46047 { "LOADSCREENDATAR", 1, 0, 0, 0},
46048 { "LOADSCREENDATAV", 1, 1, 0, 0},
46049
46050 { "LOADBITMAPDATAR", 1, 0, 0, 0},
46051 { "LOADBITMAPDATAV", 1, 1, 0, 0},
46052
46053 { "LOADSHOPR", 1, 0, 0, 0},
46054 { "LOADSHOPV", 1, 1, 0, 0},
46055
46056 { "LOADINFOSHOPR", 1, 0, 0, 0},
46057 { "LOADINFOSHOPV", 1, 1, 0, 0},
46058
46059 { "LOADMESSAGEDATAR", 1, 0, 0, 0},
46060 { "LOADMESSAGEDATAV", 1, 1, 0, 0},
46061 { "MESSAGEDATASETSTRINGR", 1, 0, 0, 0},
46062 { "MESSAGEDATASETSTRINGV", 1, 1, 0, 0},
46063 { "MESSAGEDATAGETSTRINGR", 1, 0, 0, 0},
46064 { "MESSAGEDATAGETSTRINGV", 1, 1, 0, 0},
46065
46066 { "LOADDMAPDATAR", 1, 0, 0, 0},
46067 { "LOADDMAPDATAV", 1, 1, 0, 0},
46068 { "DMAPDATAGETNAMER", 1, 0, 0, 0},
46069 { "DMAPDATAGETNAMEV", 1, 1, 0, 0},
46070 { "DMAPDATASETNAMER", 1, 0, 0, 0},
46071 { "DMAPDATASETNAMEV", 1, 1, 0, 0},
46072 { "DMAPDATAGETTITLER", 1, 0, 0, 0},
46073 { "DMAPDATAGETTITLEV", 1, 1, 0, 0},
46074 { "DMAPDATASETTITLER", 1, 0, 0, 0},
46075 { "DMAPDATASETTITLEV", 1, 1, 0, 0},
46076
46077 { "DMAPDATAGETINTROR", 1, 0, 0, 0},
46078 { "DMAPDATAGETINTROV", 1, 1, 0, 0},
46079 { "DMAPDATANSETITROR", 1, 0, 0, 0},
46080 { "DMAPDATASETINTROV", 1, 1, 0, 0},
46081 { "DMAPDATAGETMUSICR", 1, 0, 0, 0},
46082 { "DMAPDATAGETMUSICV", 1, 1, 0, 0},
46083 { "DMAPDATASETMUSICR", 1, 0, 0, 0},
46084 { "DMAPDATASETMUSICV", 1, 1, 0, 0},
46085
46086 { "ADJUSTSFXVOLUMER", 1, 0, 0, 0},
46087 { "ADJUSTSFXVOLUMEV", 1, 1, 0, 0},
46088
46089 { "ADJUSTVOLUMER", 1, 0, 0, 0},
46090 { "ADJUSTVOLUMEV", 1, 1, 0, 0},
46091
46092 { "FXWAVYR", 1, 0, 0, 0},
46093 { "FXWAVYV", 1, 1, 0, 0},
46094
46095 { "FXZAPR", 1, 0, 0, 0},
46096 { "FXZAPV", 1, 1, 0, 0},
46097
46098 { "GREYSCALER", 1, 0, 0, 0},
46099 { "GREYSCALEV", 1, 1, 0, 0},
46100 { "RETURN", 0, 0, 0, 0},
46101 { "MONOCHROMER", 1, 0, 0, 0},
46102 { "MONOCHROMEV", 1, 1, 0, 0},
46103 { "CLEARTINT", 0, 0, 0, 0},
46104 { "TINT", 0, 0, 0, 0},
46105 { "MONOHUE", 0, 0, 0, 0},
46106
46107 { "BMPRECTR", 0, 0, 0, 0},
46108 { "BMPCIRCLER", 0, 0, 0, 0},
46109 { "BMPARCR", 0, 0, 0, 0},
46110 { "BMPELLIPSER", 0, 0, 0, 0},
46111 { "BMPLINER", 0, 0, 0, 0},
46112 { "BMPSPLINER", 0, 0, 0, 0},
46113 { "BMPPUTPIXELR", 0, 0, 0, 0},
46114 { "BMPDRAWTILER", 0, 0, 0, 0},
46115 { "BMPDRAWCOMBOR", 0, 0, 0, 0},
46116 { "BMPFASTTILER", 0, 0, 0, 0},
46117 { "BMPFASTCOMBOR", 0, 0, 0, 0},
46118 { "BMPDRAWCHARR", 0, 0, 0, 0},
46119 { "BMPDRAWINTR", 0, 0, 0, 0},
46120 { "BMPDRAWSTRINGR", 0, 0, 0, 0},
46121 { "BMPQUADR", 0, 0, 0, 0},
46122 { "BMPQUAD3DR", 0, 0, 0, 0},
46123 { "BMPTRIANGLER", 0, 0, 0, 0},
46124 { "BMPTRIANGLE3DR", 0, 0, 0, 0},
46125 { "BMPPOLYGONR", 0, 0, 0, 0},
46126 { "BMPDRAWLAYERR", 0, 0, 0, 0},
46127 { "BMPDRAWSCREENR", 0, 0, 0, 0},
46128 { "BMPBLIT", 0, 0, 0, 0},
46129
46130 { "LINKWARPEXR", 1, 0, 0, 0},
46131 { "LINKWARPEXV", 1, 1, 0, 0},
46132 { "LINKEXPLODER", 1, 0, 0, 0},
46133 { "LINKEXPLODEV", 1, 1, 0, 0},
46134 { "NPCEXPLODER", 1, 0, 0, 0},
46135 { "NPCEXPLODEV", 1, 1, 0, 0},
46136
46137 { "ITEMEXPLODER", 1, 0, 0, 0},
46138 { "ITEMEXPLODEV", 1, 1, 0, 0},
46139 { "LWEAPONEXPLODER", 1, 0, 0, 0},
46140 { "LWEAPONEXPLODEV", 1, 1, 0, 0},
46141 { "EWEAPONEXPLODER", 1, 0, 0, 0},
46142 { "EWEAPONEXPLODEV", 1, 1, 0, 0},
46143 { "RUNITEMSCRIPT", 0, 0, 0, 0},
46144 { "GETRTCTIMER", 1, 0, 0, 0},
46145 { "GETRTCTIMEV", 1, 1, 0, 0},
46146
46147 //new npc functions for npc scripts
46148 { "NPCDEAD", 1, 0, 0, 0},
46149 { "NPCKICKBUCKET", 0, 0, 0, 0},
46150 { "NPCSTOPBGSFX", 0, 0, 0, 0},
46151 { "NPCCANMOVE", 1, 0, 0, 0},
46152 { "NPCNEWDIR8", 0, 0, 0, 0},
46153 { "NPCNEWDIR", 0, 0, 0, 0},
46154 { "NPCCONSTWALK", 0, 0, 0, 0},
46155 { "NPCCONSTWALK8", 0, 0, 0, 0},
46156 { "NPCVARWALK", 0, 0, 0, 0},
46157 { "NPCVARWALK8", 0, 0, 0, 0},
46158 { "NPCHALTWALK", 0, 0, 0, 0},
46159 { "NPCHALTWALK8", 0, 0, 0, 0},
46160 { "NPCFLOATWALK", 0, 0, 0, 0},
46161 // moved to a var: { "NPCLINEDUP", 0, 0, 0, 0},
46162 { "NPCLINKINRANGE", 1, 0, 0, 0},
46163 { "NPCATTACK", 0, 0, 0, 0},
46164 { "NPCPLACEONAXIS", 0, 0, 0, 0},
46165 { "NPCADD", 1, 0, 0, 0},
46166 { "NPCFIREBREATH", 0, 0, 0, 0},
46167 { "NPCCANSLIDE", 1, 0, 0, 0},
46168 { "NPCSLIDE", 1, 0, 0, 0},
46169 { "NPCHITWITH", 1, 0, 0, 0},
46170 { "NPCGETINITDLABEL", 0, 0, 0, 0},
46171 // moved to a var: { "NPCCOLLISION", 0, 0, 0, 0}, //how to implement this?
46172 { "GAMECONTINUE", 0, 0, 0, 0},
46173 { "MAPDATAISSOLID", 1, 0, 0, 0},
46174 { "SHOWF6SCREEN", 0, 0, 0, 0},
46175 { "NPCDATAGETNAME", 1, 0, 0, 0},
46176 { "PLAYENHMUSICEX", 2, 0, 0, 0},
46177 { "GETENHMUSICPOS", 1, 0, 0, 0},
46178 { "SETENHMUSICPOS", 1, 0, 0, 0},
46179 { "SETENHMUSICSPEED", 1, 0, 0, 0},
46180 { "ISVALIDBITMAP", 1, 0, 0, 0},
46181 { "READBITMAP", 0, 0, 0, 0},
46182 { "WRITEBITMAP", 0, 0, 0, 0},
46183 { "ALLOCATEBITMAP", 1, 0, 0, 0},
46184 { "CLEARBITMAP", 0, 0, 0, 0},
46185 { "REGENERATEBITMAP", 0, 0, 0, 0},
46186 { "BMPBLITTO", 0, 0, 0, 0},
46187
46188 { "BMPDRAWSCREENSOLIDR", 0, 0, 0, 0},
46189 { "BMPDRAWSCREENCOMBOFR", 0, 0, 0, 0},
46190 { "BMPDRAWSCREENCOMBOIR", 0, 0, 0, 0},
46191 { "BMPDRAWSCREENCOMBOTR", 0, 0, 0, 0},
46192 { "BMPDRAWSCREENSOLID2R", 0, 0, 0, 0},
46193 { "GRAPHICSGETPIXEL", 1, 0, 0, 0},
46194
46195 { "BMPDRAWLAYERSOLIDR", 0, 0, 0, 0},
46196 { "BMPDRAWLAYERCFLAGR", 0, 0, 0, 0},
46197 { "BMPDRAWLAYERCTYPER", 0, 0, 0, 0},
46198 { "BMPDRAWLAYERCIFLAGR", 0, 0, 0, 0},
46199 { "BMPDRAWLAYERSOLIDITYR", 0, 0, 0, 0},
46200 { "BMPMODE7", 0, 0, 0, 0},
46201 { "BITMAPGETPIXEL", 0, 0, 0, 0},
46202 { "NOP", 0, 0, 0, 0},
46203 { "STRINGCOMPARE", 1, 0, 0, 0},
46204 { "STRINGNCOMPARE", 1, 0, 0, 0},
46205 { "STRINGLENGTH", 2, 0, 0, 0},
46206 { "STRINGCOPY", 2, 0, 0, 0},
46207 { "CASTBOOLI", 1, 0, 0, 0},
46208 { "CASTBOOLF", 1, 0, 0, 0},
46209 { "SETTRUEI", 1, 0, 0, 0},
46210 { "SETFALSEI", 1, 0, 0, 0},
46211 { "SETMOREI", 1, 0, 0, 0},
46212 { "SETLESSI", 1, 0, 0, 0},
46213
46214 { "ARRAYCOPY", 2, 0, 0, 0},
46215 { "ARRAYNCOPY", 1, 0, 0, 0},
46216
46217 //1 INPUT, NO RETURN
46218 { "REMCHR", 2, 0, 0, 0},
46219 { "STRINGUPPERLOWER", 2, 0, 0, 0},
46220 { "STRINGLOWERUPPER", 2, 0, 0, 0},
46221 { "STRINGCONVERTCASE", 2, 0, 0, 0},
46222
46223 //1 input, 1 ret
46224 { "XLEN", 2, 0, 0, 0},
46225 { "XTOI", 2, 0, 0, 0},
46226 { "ILEN", 2, 0, 0, 0},
46227 { "ATOI", 2, 0, 0, 0},
46228
46229 //2 INPUT, 1 RET, based on strcmp
46230 { "STRCSPN", 1, 0, 0, 0},
46231 { "STRSTR", 1, 0, 0, 0},
46232 { "XTOA", 2, 0, 0, 0},
46233 { "ITOA", 2, 0, 0, 0},
46234 { "STRCAT", 1, 0, 0, 0},
46235 { "STRSPN", 1, 0, 0, 0},
46236 { "STRCHR", 1, 0, 0, 0},
46237 { "STRRCHR", 1, 0, 0, 0},
46238 //2 INP, 1 RET OVERLOADS
46239 { "XLEN2", 1, 0, 0, 0},
46240 { "XTOI2", 1, 0, 0, 0},
46241 { "ILEN2", 1, 0, 0, 0},
46242 { "ATOI2", 1, 0, 0, 0},
46243 { "REMCHR2", 1, 0, 0, 0},
46244
46245 //3 INPUT 1 RET
46246 { "XTOA3", 1, 0, 0, 0},
46247 { "STRCATF", 1, 0, 0, 0},
46248 { "ITOA3", 1, 0, 0, 0},
46249 { "STRSTR3", 1, 0, 0, 0},
46250 { "REMNCHR3", 1, 0, 0, 0},
46251 { "STRCAT3", 1, 0, 0, 0},
46252 { "STRNCAT3", 1, 0, 0, 0},
46253 { "STRCHR3", 1, 0, 0, 0},
46254 { "STRRCHR3", 1, 0, 0, 0},
46255 { "STRSPN3", 1, 0, 0, 0},
46256 { "STRCSPN3", 1, 0, 0, 0},
46257
46258
46259 { "UPPERTOLOWER", 2, 0, 0, 0},
46260 { "LOWERTOUPPER", 2, 0, 0, 0},
46261 { "CONVERTCASE", 2, 0, 0, 0},
46262 //Game->Get
46263 { "GETNPCSCRIPT", 1, 0, 0, 0},
46264 { "GETLWEAPONSCRIPT", 1, 0, 0, 0},
46265 { "GETEWEAPONSCRIPT", 1, 0, 0, 0},
46266 { "GETHEROSCRIPT", 1, 0, 0, 0},
46267 { "GETGLOBALSCRIPT", 1, 0, 0, 0},
46268 { "GETDMAPSCRIPT", 1, 0, 0, 0},
46269 { "GETSCREENSCRIPT", 1, 0, 0, 0},
46270 { "GETSPRITESCRIPT", 1, 0, 0, 0},
46271 { "GETUNTYPEDSCRIPT", 1, 0, 0, 0},
46272 { "GETSUBSCREENSCRIPT", 1, 0, 0, 0},
46273 { "GETNPCBYNAME", 1, 0, 0, 0},
46274 { "GETITEMBYNAME", 1, 0, 0, 0},
46275 { "GETCOMBOBYNAME", 1, 0, 0, 0},
46276 { "GETDMAPBYNAME", 1, 0, 0, 0},
46277
46278 { "SRNDR", 1, 0, 0, 0},
46279 { "SRNDV", 1, 1, 0, 0},
46280 { "SRNDRND", 1, 0, 0, 0},
46281 { "SAVEGAMESTRUCTS", 2, 0, 0, 0},
46282 { "READGAMESTRUCTS", 2, 0, 0, 0},
46283 { "ANDR32", 2, 0, 0, 0},
46284 { "ANDV32", 2, 0, 1, 0},
46285 { "ORR32", 2, 0, 0, 0},
46286 { "ORV32", 2, 0, 1, 0},
46287 { "XORR32", 2, 0, 0, 0},
46288 { "XORV32", 2, 0, 1, 0},
46289 { "BITNOT32", 1, 0, 0, 0},
46290 { "LSHIFTR32", 2, 0, 0, 0},
46291 { "LSHIFTV32", 2, 0, 1, 0},
46292 { "RSHIFTR32", 2, 0, 0, 0},
46293 { "RSHIFTV32", 2, 0, 1, 0},
46294 { "ISALLOCATEDBITMAP", 1, 0, 0, 0},
46295 { "FONTHEIGHTR", 1, 0, 0, 0},
46296 { "STRINGWIDTHR", 2, 0, 0, 0},
46297 { "CHARWIDTHR", 2, 0, 0, 0},
46298 { "MESSAGEWIDTHR", 1, 0, 0, 0},
46299 { "MESSAGEHEIGHTR", 1, 0, 0, 0},
46300 { "ISVALIDARRAY", 1, 0, 0, 0},
46301 { "DIREXISTS", 1, 0, 0, 0},
46302 { "GAMESAVEQUIT", 0, 0, 0, 0},
46303 { "GAMESAVECONTINUE", 0, 0, 0, 0},
46304 { "DRAWTILECLOAKEDR", 0, 0, 0, 0},
46305 { "BMPDRAWTILECLOAKEDR", 0, 0, 0, 0},
46306 { "DRAWCOMBOCLOAKEDR", 0, 0, 0, 0},
46307 { "BMPDRAWCOMBOCLOAKEDR", 0, 0, 0, 0},
46308 { "NPCKNOCKBACK", 2, 0, 0, 0},
46309 { "CLOSEWIPE", 0, 0, 0, 0},
46310 { "OPENWIPESHAPE", 1, 0, 0, 0},
46311 { "CLOSEWIPESHAPE", 1, 0, 0, 0},
46312 { "FILEEXISTS", 1, 0, 0, 0},
46313 { "BITMAPCLEARTOCOLOR", 0, 0, 0, 0},
46314 { "LOADNPCBYSUID", 1, 0, 0, 0},
46315 { "LOADLWEAPONBYSUID", 1, 0, 0, 0},
46316 { "LOADWEAPONCBYSUID", 1, 0, 0, 0},
46317 { "LOADDROPSETR", 1, 0, 0, 0},
46318 { "LOADTMPSCR", 1, 0, 0, 0},
46319 { "LOADSCROLLSCR", 1, 0, 0, 0},
46320 { "MAPDATAISSOLIDLYR", 1, 0, 0, 0},
46321 { "ISSOLIDLAYER", 1, 0, 0, 0},
46322 { "BREAKPOINT", 1, 0, 0, 0},
46323 { "TOBYTE", 1, 0, 0, 0},
46324 { "TOWORD", 1, 0, 0, 0},
46325 { "TOSHORT", 1, 0, 0, 0},
46326 { "TOSIGNEDBYTE", 1, 0, 0, 0},
46327 { "TOINTEGER", 1, 0, 0, 0},
46328 { "FLOOR", 1, 0, 0, 0},
46329 { "CEILING", 1, 0, 0, 0},
46330
46331 { "FILECLOSE", 0, 0, 0, 0},
46332 { "FILEFREE", 0, 0, 0, 0},
46333 { "FILEISALLOCATED", 0, 0, 0, 0},
46334 { "FILEISVALID", 0, 0, 0, 0},
46335 { "FILEALLOCATE", 0, 0, 0, 0},
46336 { "FILEFLUSH", 0, 0, 0, 0},
46337 { "FILEGETCHAR", 0, 0, 0, 0},
46338 { "FILEREWIND", 0, 0, 0, 0},
46339 { "FILECLEARERR", 0, 0, 0, 0},
46340
46341 { "FILEOPEN", 1, 0, 0, 0},
46342 { "FILECREATE", 1, 0, 0, 0},
46343 { "FILEREADSTR", 1, 0, 0, 0},
46344 { "FILEWRITESTR", 1, 0, 0, 0},
46345 { "FILEPUTCHAR", 1, 0, 0, 0},
46346 { "FILEUNGETCHAR", 1, 0, 0, 0},
46347
46348 { "FILEREADCHARS", 2, 0, 0, 0},
46349 { "FILEREADINTS", 2, 0, 0, 0},
46350 { "FILEWRITECHARS", 2, 0, 0, 0},
46351 { "FILEWRITEINTS", 2, 0, 0, 0},
46352 { "FILESEEK", 2, 0, 0, 0},
46353 { "FILEOPENMODE", 2, 0, 0, 0},
46354 { "FILEGETERROR", 1, 0, 0, 0},
46355
46356 { "BITMAPFREE", 0, 0, 0, 0},
46357
46358 { "POPARGS", 2, 0, 1, 0},
46359 { "GAMERELOAD", 0, 0, 0, 0},
46360
46361 { "READPODARRAYR", 2, 0, 0, 0},
46362 { "READPODARRAYV", 2, 0, 1, 0},
46363 { "WRITEPODARRAYRR", 2, 0, 0, 0},
46364 { "WRITEPODARRAYRV", 2, 0, 1, 0},
46365 { "WRITEPODARRAYVR", 2, 1, 0, 0},
46366 { "WRITEPODARRAYVV", 2, 1, 1, 0},
46367
46368 { "PRINTFV", 1, 1, 0, 0},
46369 { "SPRINTFV", 1, 1, 0, 0},
46370
46371 { "STRCMPR", 2, 0, 0, 0},
46372 { "STRICMPR", 2, 0, 0, 0},
46373 { "STRINGICOMPARE", 1, 0, 0, 0},
46374 { "STRINGNICOMPARE", 1, 0, 0, 0},
46375
46376 { "FILEREMOVE", 0, 0, 0, 0},
46377 { "FILESYSREMOVE", 1, 0, 0, 0},
46378
46379 { "DRAWSTRINGR2", 0, 0, 0, 0},
46380 { "BMPDRAWSTRINGR2", 0, 0, 0, 0},
46381
46382 { "MODULEGETIC", 2, 0, 0, 0},
46383 { "ITOACAT", 2, 0, 0, 0},
46384
46385 { "FRAMER", 0, 0, 0, 0},
46386 { "BMPFRAMER", 0, 0, 0, 0},
46387
46388 { "LOADDIRECTORYR", 1, 0, 0, 0},
46389 { "DIRECTORYGET", 2, 0, 0, 0},
46390 { "DIRECTORYRELOAD", 0, 0, 0, 0},
46391 { "DIRECTORYFREE", 0, 0, 0, 0},
46392 { "FILEWRITEBYTES", 2, 0, 0, 0},
46393 { "GETCOMBOSCRIPT", 1, 0, 0, 0},
46394 { "FILEREADBYTES", 2, 0, 0, 0},
46395
46396 { "LOADRNG", 0, 0, 0, 0},
46397 { "RNGRAND1", 0, 0, 0, 0},
46398 { "RNGRAND2", 1, 0, 0, 0},
46399 { "RNGRAND3", 2, 0, 0, 0},
46400 { "RNGLRAND1", 0, 0, 0, 0},
46401 { "RNGLRAND2", 1, 0, 0, 0},
46402 { "RNGLRAND3", 2, 0, 0, 0},
46403 { "RNGSEED", 1, 0, 0, 0},
46404 { "RNGRSEED", 0, 0, 0, 0},
46405 { "RNGFREE", 0, 0, 0, 0},
46406 { "LWPNDEL", 0, 0, 0, 0},
46407 { "EWPNDEL", 0, 0, 0, 0},
46408 { "ITEMDEL", 0, 0, 0, 0},
46409 { "BMPWRITETILE", 0, 0, 0, 0},
46410 { "BMPDITHER", 0, 0, 0, 0},
46411 { "BMPREPLCOLOR", 0, 0, 0, 0},
46412 { "BMPSHIFTCOLOR", 0, 0, 0, 0},
46413 { "BMPMASKDRAW", 0, 0, 0, 0},
46414 { "RESIZEARRAYR", 2, 0, 0, 0},
46415 { "BSHOPNAMEGET", 1, 0, 0, 0},
46416 { "BSHOPNAMESET", 1, 0, 0, 0},
46417 { "BOTTLENAMEGET", 1, 0, 0, 0},
46418 { "BOTTLENAMESET", 1, 0, 0, 0},
46419 { "LOADBOTTLETYPE", 1, 0, 0, 0},
46420 { "LOADBSHOPDATA", 1, 0, 0, 0},
46421 { "SWITCHNPC", 1, 0, 0, 0},
46422 { "SWITCHCMB", 2, 0, 0, 0},
46423 { "SWITCHITM", 1, 0, 0, 0},
46424 { "SWITCHLW", 1, 0, 0, 0},
46425 { "SWITCHEW", 1, 0, 0, 0},
46426 { "SCREENDOSPAWN", 0, 0, 0, 0},
46427 { "NPCMOVEPAUSED", 0, 0, 0, 0},
46428 { "NPCMOVE", 0, 0, 0, 0},
46429 { "NPCMOVEANGLE", 0, 0, 0, 0},
46430 { "NPCMOVEXY", 0, 0, 0, 0},
46431 { "NPCCANMOVEDIR", 0, 0, 0, 0},
46432 { "NPCCANMOVEANGLE", 0, 0, 0, 0},
46433 { "NPCCANMOVEXY", 0, 0, 0, 0},
46434 { "SELECTXWPNR", 1, 0, 0, 0},
46435 { "SELECTYWPNR", 1, 0, 0, 0},
46436 { "BITMAPOWN", 0, 0, 0, 0},
46437 { "FILEOWN", 0, 0, 0, 0},
46438 { "DIRECTORYOWN", 0, 0, 0, 0},
46439 { "RNGOWN", 0, 0, 0, 0},
46440 { "LOADGENERICDATA", 1, 0, 0, 0},
46441 { "RUNGENFRZSCR", 1, 0, 0, 0},
46442 { "WAITTO", 2, 0, 0, 0},
46443 { "GETGENERICSCRIPT", 1, 0, 0, 0},
46444 { "KILLPLAYER", 1, 0, 0, 0},
46445 { "DEGTORAD", 2, 0, 0, 0},
46446 { "RADTODEG", 2, 0, 0, 0},
46447 { "LWPNMAKEANGULAR", 1, 0, 0, 0},
46448 { "EWPNMAKEANGULAR", 1, 0, 0, 0},
46449 { "LWPNMAKEDIRECTIONAL", 1, 0, 0, 0},
46450 { "EWPNMAKEDIRECTIONAL", 1, 0, 0, 0},
46451 { "BMPMASKDRAW2", 0, 0, 0, 0},
46452 { "BMPMASKDRAW3", 0, 0, 0, 0},
46453 { "BMPMASKBLIT", 0, 0, 0, 0},
46454 { "BMPMASKBLIT2", 0, 0, 0, 0},
46455 { "BMPMASKBLIT3", 0, 0, 0, 0},
46456 { "SUBV2", 2, 1, 0, 0},
46457 { "DIVV2", 2, 1, 0, 0},
46458 { "COMPAREV2", 2, 1, 0, 0},
46459 { "MODV2", 2, 1, 0, 0},
46460 { "STACKFREE", 0, 0, 0, 0},
46461 { "STACKOWN", 0, 0, 0, 0},
46462 { "STACKGET", 1, 0, 0, 0},
46463 { "STACKSET", 2, 0, 0, 0},
46464 { "STACKPOPBACK", 0, 0, 0, 0},
46465 { "STACKPOPFRONT", 0, 0, 0, 0},
46466 { "STACKPEEKBACK", 0, 0, 0, 0},
46467 { "STACKPEEKFRONT", 0, 0, 0, 0},
46468 { "STACKPUSHBACK", 1, 0, 0, 0},
46469 { "STACKPUSHFRONT", 1, 0, 0, 0},
46470 { "LOADSTACK", 0, 0, 0, 0},
46471 { "STACKCLEAR", 0, 0, 0, 0},
46472 { "POWERV2", 2, 1, 0, 0},
46473 { "LPOWERR", 2, 0, 0, 0},
46474 { "LPOWERV", 2, 0, 1, 0},
46475 { "LPOWERV2", 2, 1, 0, 0},
46476 { "SCRTRIGGERCOMBO", 2, 0, 0, 0},
46477 { "WAITEVENT", 0, 0, 0, 0},
46478 { "OWNARRAYR", 1, 0, 0, 0},
46479 { "DESTROYARRAYR", 1, 0, 0, 0},
46480 { "GRAPHICSCOUNTCOLOR", 1, 0, 0, 0},
46481 { "WRITEPODSTRING", 1, 0, 0, 1},
46482 { "WRITEPODARRAY", 1, 0, 0, 2},
46483 { "ZCLASS_CONSTRUCT", 1, 0, 0, 2},
46484 { "ZCLASS_READ", 2, 0, 1, 0},
46485 { "ZCLASS_WRITE", 2, 0, 1, 0},
46486 { "ZCLASS_FREE", 1, 0, 0, 0},
46487 { "ZCLASS_OWN", 1, 0, 0, 0},
46488 { "STARTDESTRUCTOR", 0, 0, 0, 1},
46489 { "ZCLASS_GLOBALIZE", 1, 0, 0, 0},
46490 { "LOADD", 2, 0, 1, 0},
46491 { "STORED", 2, 0, 1, 0},
46492 { "OBJ_OWN_BITMAP", 2, 0, 1, 0},
46493 { "OBJ_OWN_PALDATA", 2, 0, 1, 0},
46494 { "OBJ_OWN_FILE", 2, 0, 1, 0},
46495 { "OBJ_OWN_DIR", 2, 0, 1, 0},
46496 { "OBJ_OWN_STACK", 2, 0, 1, 0},
46497 { "OBJ_OWN_RNG", 2, 0, 1, 0},
46498 { "OBJ_OWN_CLASS", 2, 0, 1, 0},
46499 { "OBJ_OWN_ARRAY", 2, 0, 1, 0},
46500 { "QUIT_NO_DEALLOC", 0, 0, 0, 0},
46501 { "GAMESETCUSTOMCURSOR", 0, 0, 0, 0},
46502 { "NPCCANPLACE", 0, 0, 0, 0},
46503 { "ITEMGETDISPLAYNAME", 1, 0, 0, 0},
46504 { "ITEMSETDISPLAYNAME", 1, 0, 0, 0},
46505 { "ITEMGETSHOWNNAME", 1, 0, 0, 0},
46506 { "HEROMOVEXY", 0, 0, 0, 0},
46507 { "HEROCANMOVEXY", 0, 0, 0, 0},
46508 { "HEROLIFTRELEASE", 0, 0, 0, 0},
46509 { "HEROLIFTGRAB", 0, 0, 0, 0},
46510 { "LOADPORTAL", 0, 0, 0, 0},
46511 { "CREATEPORTAL", 0, 0, 0, 0},
46512 { "LOADSAVPORTAL", 0, 0, 0, 0},
46513 { "CREATESAVPORTAL", 0, 0, 0, 0},
46514 { "CREATEPALDATA", 0, 0, 0, 0 },
46515 { "CREATEPALDATACLR", 1, 0, 0, 0 },
46516 { "MIXCLR", 0, 0, 0, 0 },
46517 { "CREATERGBHEX", 1, 0, 0, 0 },
46518 { "CREATERGB", 0, 0, 0, 0 },
46519 { "PALDATALOADLEVEL", 1, 0, 0, 0 },
46520 { "PALDATALOADSPRITE", 1, 0, 0, 0 },
46521 { "PALDATALOADMAIN", 0, 0, 0, 0 },
46522 { "PALDATALOADCYCLE", 1, 0, 0, 0 },
46523 { "PALDATALOADBITMAP", 1, 0, 0, 0 },
46524 { "PALDATAWRITELEVEL", 1, 0, 0, 0 },
46525 { "PALDATAWRITELEVELCS", 2, 0, 0, 0 },
46526 { "PALDATAWRITESPRITE", 1, 0, 0, 0 },
46527 { "PALDATAWRITESPRITECS", 2, 0, 0, 0 },
46528 { "PALDATAWRITEMAIN", 0, 0, 0, 0 },
46529 { "PALDATAWRITEMAINCS", 1, 0, 0, 0 },
46530 { "PALDATAWRITECYCLE", 1, 0, 0, 0 },
46531 { "PALDATAWRITECYCLECS", 2, 0, 0, 0 },
46532 { "PALDATAVALIDCLR", 1, 0, 0, 0 },
46533 { "PALDATACLEARCLR", 1, 0, 0, 0 },
46534 { "PALDATACLEARCSET", 1, 0, 0, 0 },
46535 { "PALDATAMIX", 0, 0, 0, 0 },
46536 { "PALDATAMIXCS", 0, 0, 0, 0 },
46537 { "PALDATACOPY", 1, 0, 0, 0 },
46538 { "PALDATACOPYCSET", 0, 0, 0, 0 },
46539 { "PALDATAFREE", 0, 0, 0, 0 },
46540 { "PALDATAOWN", 0, 0, 0, 0 },
46541 { "MAXVARG", 0, 0, 0, 0 },
46542 { "MINVARG", 0, 0, 0, 0 },
46543 { "CHOOSEVARG", 0, 0, 0, 0 },
46544 { "PUSHVARGV", 1, 1, 0, 0 },
46545 { "PUSHVARGR", 1, 0, 0, 0 },
46546 { "PRINTFVARG", 0, 0, 0, 0 },
46547 { "SPRINTFVARG", 0, 0, 0, 0 },
46548 { "TRACELR", 1, 0, 0, 0 },
46549 { "WAITFRAMESR", 1, 0, 0, 0 },
46550 { "RESRVD_OP_Z3_01", 0, 0, 0, 0 },
46551 { "RESRVD_OP_Z3_02", 0, 0, 0, 0 },
46552 { "RESRVD_OP_Z3_03", 0, 0, 0, 0 },
46553 { "RESRVD_OP_Z3_04", 0, 0, 0, 0 },
46554 { "RESRVD_OP_Z3_05", 0, 0, 0, 0 },
46555 { "RESRVD_OP_Z3_06", 0, 0, 0, 0 },
46556 { "RESRVD_OP_Z3_07", 0, 0, 0, 0 },
46557 { "RESRVD_OP_Z3_08", 0, 0, 0, 0 },
46558 { "RESRVD_OP_Z3_09", 0, 0, 0, 0 },
46559 { "RESRVD_OP_Z3_10", 0, 0, 0, 0 },
46560 { "PORTALREMOVE", 0, 0, 0, 0 },
46561 { "SAVEDPORTALREMOVE", 0, 0, 0, 0 },
46562 { "SAVEDPORTALGENERATE", 0, 0, 0, 0 },
46563 { "PORTALUSESPRITE", 1, 0, 0, 0 },
46564 { "HEROMOVEATANGLE", 0, 0, 0, 0 },
46565 { "HEROCANMOVEATANGLE", 0, 0, 0, 0 },
46566 { "HEROMOVE", 0, 0, 0, 0 },
46567 { "HEROCANMOVE", 0, 0, 0, 0 },
46568 { "DRAWLIGHT_CIRCLE", 0, 0, 0, 0 },
46569 { "DRAWLIGHT_SQUARE", 0, 0, 0, 0 },
46570 { "DRAWLIGHT_CONE", 0, 0, 0, 0 },
46571 { "PEEK", 1, 0, 0, 0 },
46572 { "PEEKATV", 2, 0, 1, 0 },
46573 { "MAKEVARGARRAY", 0, 0, 0, 0 },
46574 { "PRINTFA", 0, 0, 0, 0 },
46575 { "SPRINTFA", 0, 0, 0, 0 },
46576 { "CURRENTITEMID", 0, 0, 0, 0 },
46577 { "ARRAYPUSH", 0, 0, 0, 0 },
46578 { "ARRAYPOP", 0, 0, 0, 0 },
46579 { "LOADSUBDATARV", 2, 0, 1, 0 },
46580 { "SWAPSUBSCREENV", 1, 1, 0, 0 },
46581 { "SUBDATA_GET_NAME", 1, 0, 0, 0 },
46582 { "SUBDATA_SET_NAME", 1, 0, 0, 0 },
46583 { "CONVERTFROMRGB", 0, 0, 0, 0 },
46584 { "CONVERTTORGB", 0, 0, 0, 0 },
46585 { "GETENHMUSICLEN", 1, 0, 0, 0 },
46586 { "SETENHMUSICLOOP", 2, 0, 0, 0 },
46587 { "PLAYSOUNDEX", 0, 0, 0, 0 },
46588 { "GETSFXCOMPLETION", 1, 0, 0, 0 },
46589 { "ENHCROSSFADE", 0, 0, 0, 0 },
46590 { "RESRVD_OP_MOOSH_08", 0, 0, 0, 0 },
46591 { "RESRVD_OP_MOOSH_09", 0, 0, 0, 0 },
46592 { "RESRVD_OP_MOOSH_10", 0, 0, 0, 0 },
46593
46594 { "SUBDATA_SWAP_PAGES", 0, 0, 0, 0 },
46595 { "SUBPAGE_FIND_WIDGET", 0, 0, 0, 0 },
46596 { "SUBPAGE_MOVE_SEL", 0, 0, 0, 0 },
46597 { "SUBPAGE_SWAP_WIDG", 0, 0, 0, 0 },
46598 { "SUBPAGE_NEW_WIDG", 0, 0, 0, 0 },
46599 { "SUBPAGE_DELETE", 0, 0, 0, 0 },
46600 { "SUBWIDG_GET_SELTEXT_OVERRIDE", 1, 0, 0, 0 },
46601 { "SUBWIDG_SET_SELTEXT_OVERRIDE", 1, 0, 0, 0 },
46602 { "SUBWIDG_TY_GETTEXT", 1, 0, 0, 0 },
46603 { "SUBWIDG_TY_SETTEXT", 1, 0, 0, 0 },
46604
46605 { "SUBPAGE_FIND_WIDGET_BY_LABEL", 0, 0, 0, 0 },
46606
46607 { "SUBWIDG_GET_LABEL", 1, 0, 0, 0 },
46608 { "SUBWIDG_SET_LABEL", 1, 0, 0, 0 },
46609
46610 { "", 0, 0, 0, 0 }
46611 };
46612
46613
46614 script_variable ZASMVars[]=
46615 {
46616 //name id maxcount multiple
46617 { "D", D(0), 8, 0 },
46618 { "A", A(0), 2, 0 },
46619 { "DATA", DATA, 0, 0 },
46620 { "CSET", FCSET, 0, 0 },
46621 { "DELAY", DELAY, 0, 0 },
46622 { "X", FX, 0, 0 },
46623 { "Y", FY, 0, 0 },
46624 { "XD", XD, 0, 0 },
46625 { "YD", YD, 0, 0 },
46626 { "XD2", XD2, 0, 0 },
46627 { "YD2", YD2, 0, 0 },
46628 { "FLAG", FLAG, 0, 0 },
46629 { "WIDTH", WIDTH, 0, 0 },
46630 { "HEIGHT", HEIGHT, 0, 0 },
46631 { "LINK", LINK, 0, 0 },
46632 { "FFFLAGSD", FFFLAGSD, 0, 0 },
46633 { "FFCWIDTH", FFCWIDTH, 0, 0 },
46634 { "FFCHEIGHT", FFCHEIGHT, 0, 0 },
46635 { "FFTWIDTH", FFTWIDTH, 0, 0 },
46636 { "FFTHEIGHT", FFTHEIGHT, 0, 0 },
46637 { "FFLINK", FFLINK, 0, 0 },
46638 // { "COMBOD", COMBOD(0), 176, 3 },
46639 // { "COMBOC", COMBOC(0), 176, 3 },
46640 // { "COMBOF", COMBOF(0), 176, 3 },
46641 { "INPUTSTART", INPUTSTART, 0, 0 },
46642 { "INPUTUP", INPUTUP, 0, 0 },
46643 { "INPUTDOWN", INPUTDOWN, 0, 0 },
46644 { "INPUTLEFT", INPUTLEFT, 0, 0 },
46645 { "INPUTRIGHT", INPUTRIGHT, 0, 0 },
46646 { "INPUTA", INPUTA, 0, 0 },
46647 { "INPUTB", INPUTB, 0, 0 },
46648 { "INPUTL", INPUTL, 0, 0 },
46649 { "INPUTR", INPUTR, 0, 0 },
46650 { "INPUTMOUSEX", INPUTMOUSEX, 0, 0 },
46651 { "INPUTMOUSEY", INPUTMOUSEY, 0, 0 },
46652 { "LINKX", LINKX, 0, 0 },
46653 { "LINKY", LINKY, 0, 0 },
46654 { "LINKZ", LINKZ, 0, 0 },
46655 { "LINKJUMP", LINKJUMP, 0, 0 },
46656 { "LINKDIR", LINKDIR, 0, 0 },
46657 { "LINKHITDIR", LINKHITDIR, 0, 0 },
46658 { "LINKHP", LINKHP, 0, 0 },
46659 { "LINKMP", LINKMP, 0, 0 },
46660 { "LINKMAXHP", LINKMAXHP, 0, 0 },
46661 { "LINKMAXMP", LINKMAXMP, 0, 0 },
46662 { "LINKACTION", LINKACTION, 0, 0 },
46663 { "LINKHELD", LINKHELD, 0, 0 },
46664 { "LINKITEMD", LINKITEMD, 0, 0 },
46665 { "LINKSWORDJINX", LINKSWORDJINX, 0, 0 },
46666 { "LINKITEMJINX", LINKITEMJINX, 0, 0 },
46667 { "LINKDRUNK", LINKDRUNK, 0, 0 },
46668 { "ITEMX", ITEMX, 0, 0 },
46669 { "ITEMY", ITEMY, 0, 0 },
46670 { "ITEMZ", ITEMZ, 0, 0 },
46671 { "ITEMJUMP", ITEMJUMP, 0, 0 },
46672 { "ITEMDRAWTYPE", ITEMDRAWTYPE, 0, 0 },
46673 { "ITEMID", ITEMID, 0, 0 },
46674 { "ITEMTILE", ITEMTILE, 0, 0 },
46675 { "ITEMOTILE", ITEMOTILE, 0, 0 },
46676 { "ITEMCSET", ITEMCSET, 0, 0 },
46677 { "ITEMFLASHCSET", ITEMFLASHCSET, 0, 0 },
46678 { "ITEMFRAMES", ITEMFRAMES, 0, 0 },
46679 { "ITEMFRAME", ITEMFRAME, 0, 0 },
46680 { "ITEMASPEED", ITEMASPEED, 0, 0 },
46681 { "ITEMDELAY", ITEMDELAY, 0, 0 },
46682 { "ITEMFLASH", ITEMFLASH, 0, 0 },
46683 { "ITEMFLIP", ITEMFLIP, 0, 0 },
46684 { "ITEMCOUNT", ITEMCOUNT, 0, 0 },
46685 { "IDATAFAMILY", IDATAFAMILY, 0, 0 },
46686 { "IDATALEVEL", IDATALEVEL, 0, 0 },
46687 { "IDATAKEEP", IDATAKEEP, 0, 0 },
46688 { "IDATAAMOUNT", IDATAAMOUNT, 0, 0 },
46689 { "IDATASETMAX", IDATASETMAX, 0, 0 },
46690 { "IDATAMAX", IDATAMAX, 0, 0 },
46691 { "IDATACOUNTER", IDATACOUNTER, 0, 0 },
46692 { "ITEMEXTEND", ITEMEXTEND, 0, 0 },
46693 { "NPCX", NPCX, 0, 0 },
46694 { "NPCY", NPCY, 0, 0 },
46695 { "NPCZ", NPCZ, 0, 0 },
46696 { "NPCJUMP", NPCJUMP, 0, 0 },
46697 { "NPCDIR", NPCDIR, 0, 0 },
46698 { "NPCRATE", NPCRATE, 0, 0 },
46699 { "NPCSTEP", NPCSTEP, 0, 0 },
46700 { "NPCFRAMERATE", NPCFRAMERATE, 0, 0 },
46701 { "NPCHALTRATE", NPCHALTRATE, 0, 0 },
46702 { "NPCDRAWTYPE", NPCDRAWTYPE, 0, 0 },
46703 { "NPCHP", NPCHP, 0, 0 },
46704 { "NPCID", NPCID, 0, 0 },
46705 { "NPCDP", NPCDP, 0, 0 },
46706 { "NPCWDP", NPCWDP, 0, 0 },
46707 { "NPCOTILE", NPCOTILE, 0, 0 },
46708 { "NPCENEMY", NPCENEMY, 0, 0 },
46709 { "NPCWEAPON", NPCWEAPON, 0, 0 },
46710 { "NPCITEMSET", NPCITEMSET, 0, 0 },
46711 { "NPCCSET", NPCCSET, 0, 0 },
46712 { "NPCBOSSPAL", NPCBOSSPAL, 0, 0 },
46713 { "NPCBGSFX", NPCBGSFX, 0, 0 },
46714 { "NPCCOUNT", NPCCOUNT, 0, 0 },
46715 { "GD", GD(0), 1024, 0 },
46716 { "SDD", SDD, 0, 0 },
46717 { "GDD", GDD, 0, 0 },
46718 { "SDDD", SDDD, 0, 0 },
46719 { "SCRDOORD", SCRDOORD, 0, 0 },
46720 { "GAMEDEATHS", GAMEDEATHS, 0, 0 },
46721 { "GAMECHEAT", GAMECHEAT, 0, 0 },
46722 { "GAMETIME", GAMETIME, 0, 0 },
46723 { "GAMEHASPLAYED", GAMEHASPLAYED, 0, 0 },
46724 { "GAMETIMEVALID", GAMETIMEVALID, 0, 0 },
46725 { "GAMEGUYCOUNT", GAMEGUYCOUNT, 0, 0 },
46726 { "GAMECONTSCR", GAMECONTSCR, 0, 0 },
46727 { "GAMECONTDMAP", GAMECONTDMAP, 0, 0 },
46728 { "GAMECOUNTERD", GAMECOUNTERD, 0, 0 },
46729 { "GAMEMCOUNTERD", GAMEMCOUNTERD, 0, 0 },
46730 { "GAMEDCOUNTERD", GAMEDCOUNTERD, 0, 0 },
46731 { "GAMEGENERICD", GAMEGENERICD, 0, 0 },
46732 { "GAMEMISC", GAMEMISC, 0, 0 },
46733 { "GAMEITEMSD", GAMEITEMSD, 0, 0 },
46734 { "GAMELITEMSD", GAMELITEMSD, 0, 0 },
46735 { "GAMELKEYSD", GAMELKEYSD, 0, 0 },
46736 { "SCREENSTATED", SCREENSTATED, 0, 0 },
46737 { "SCREENSTATEDD", SCREENSTATEDD, 0, 0 },
46738 { "GAMEGUYCOUNTD", GAMEGUYCOUNTD, 0, 0 },
46739 { "CURMAP", CURMAP, 0, 0 },
46740 { "CURSCR", CURSCR, 0, 0 },
46741 { "CURDSCR", CURDSCR, 0, 0 },
46742 { "CURDMAP", CURDMAP, 0, 0 },
46743 { "COMBODD", COMBODD, 0, 0 },
46744 { "COMBOCD", COMBOCD, 0, 0 },
46745 { "COMBOFD", COMBOFD, 0, 0 },
46746 { "COMBOTD", COMBOTD, 0, 0 },
46747 { "COMBOID", COMBOID, 0, 0 },
46748 { "COMBOSD", COMBOSD, 0, 0 },
46749 { "REFITEMCLASS", REFITEMCLASS, 0, 0 },
46750 { "REFITEM", REFITEM, 0, 0 },
46751 { "REFFFC", REFFFC, 0, 0 },
46752 { "REFLWPN", REFLWPN, 0, 0 },
46753 { "REFEWPN", REFEWPN, 0, 0 },
46754 { "REFLWPNCLASS", REFLWPNCLASS, 0, 0 },
46755 { "REFEWPNCLASS", REFEWPNCLASS, 0, 0 },
46756 { "REFNPC", REFNPC, 0, 0 },
46757 { "REFNPCCLASS", REFNPCCLASS, 0, 0 },
46758 { "LWPNX", LWPNX, 0, 0 },
46759 { "LWPNY", LWPNY, 0, 0 },
46760 { "LWPNZ", LWPNZ, 0, 0 },
46761 { "LWPNJUMP", LWPNJUMP, 0, 0 },
46762 { "LWPNDIR", LWPNDIR, 0, 0 },
46763 { "LWPNSTEP", LWPNSTEP, 0, 0 },
46764 { "LWPNANGULAR", LWPNANGULAR, 0, 0 },
46765 { "LWPNANGLE", LWPNANGLE, 0, 0 },
46766 { "LWPNDRAWTYPE", LWPNDRAWTYPE, 0, 0 },
46767 { "LWPNPOWER", LWPNPOWER, 0, 0 },
46768 { "LWPNDEAD", LWPNDEAD, 0, 0 },
46769 { "LWPNID", LWPNID, 0, 0 },
46770 { "LWPNTILE", LWPNTILE, 0, 0 },
46771 { "LWPNCSET", LWPNCSET, 0, 0 },
46772 { "LWPNFLASHCSET", LWPNFLASHCSET, 0, 0 },
46773 { "LWPNFRAMES", LWPNFRAMES, 0, 0 },
46774 { "LWPNFRAME", LWPNFRAME, 0, 0 },
46775 { "LWPNASPEED", LWPNASPEED, 0, 0 },
46776 { "LWPNFLASH", LWPNFLASH, 0, 0 },
46777 { "LWPNFLIP", LWPNFLIP, 0, 0 },
46778 { "LWPNCOUNT", LWPNCOUNT, 0, 0 },
46779 { "LWPNEXTEND", LWPNEXTEND, 0, 0 },
46780 { "LWPNOTILE", LWPNOTILE, 0, 0 },
46781 { "LWPNOCSET", LWPNOCSET, 0, 0 },
46782 { "EWPNX", EWPNX, 0, 0 },
46783 { "EWPNY", EWPNY, 0, 0 },
46784 { "EWPNZ", EWPNZ, 0, 0 },
46785 { "EWPNJUMP", EWPNJUMP, 0, 0 },
46786 { "EWPNDIR", EWPNDIR, 0, 0 },
46787 { "EWPNSTEP", EWPNSTEP, 0, 0 },
46788 { "EWPNANGULAR", EWPNANGULAR, 0, 0 },
46789 { "EWPNANGLE", EWPNANGLE, 0, 0 },
46790 { "EWPNDRAWTYPE", EWPNDRAWTYPE, 0, 0 },
46791 { "EWPNPOWER", EWPNPOWER, 0, 0 },
46792 { "EWPNDEAD", EWPNDEAD, 0, 0 },
46793 { "EWPNID", EWPNID, 0, 0 },
46794 { "EWPNTILE", EWPNTILE, 0, 0 },
46795 { "EWPNCSET", EWPNCSET, 0, 0 },
46796 { "EWPNFLASHCSET", EWPNFLASHCSET, 0, 0 },
46797 { "EWPNFRAMES", EWPNFRAMES, 0, 0 },
46798 { "EWPNFRAME", EWPNFRAME, 0, 0 },
46799 { "EWPNASPEED", EWPNASPEED, 0, 0 },
46800 { "EWPNFLASH", EWPNFLASH, 0, 0 },
46801 { "EWPNFLIP", EWPNFLIP, 0, 0 },
46802 { "EWPNCOUNT", EWPNCOUNT, 0, 0 },
46803 { "EWPNEXTEND", EWPNEXTEND, 0, 0 },
46804 { "EWPNOTILE", EWPNOTILE, 0, 0 },
46805 { "EWPNOCSET", EWPNOCSET, 0, 0 },
46806 { "NPCEXTEND", NPCEXTEND, 0, 0 },
46807 { "SP", SP, 0, 0 },
46808 { "SP", SP, 0, 0 },
46809 { "WAVY", WAVY, 0, 0 },
46810 { "QUAKE", QUAKE, 0, 0 },
46811 { "IDATAUSESOUND", IDATAUSESOUND, 0, 0 },
46812 { "INPUTMOUSEZ", INPUTMOUSEZ, 0, 0 },
46813 { "INPUTMOUSEB", INPUTMOUSEB, 0, 0 },
46814 { "COMBODDM", COMBODDM, 0, 0 },
46815 { "COMBOCDM", COMBOCDM, 0, 0 },
46816 { "COMBOFDM", COMBOFDM, 0, 0 },
46817 { "COMBOTDM", COMBOTDM, 0, 0 },
46818 { "COMBOIDM", COMBOIDM, 0, 0 },
46819 { "COMBOSDM", COMBOSDM, 0, 0 },
46820 { "SCRIPTRAM", SCRIPTRAM, 0, 0 },
46821 { "GLOBALRAM", GLOBALRAM, 0, 0 },
46822 { "SCRIPTRAMD", SCRIPTRAMD, 0, 0 },
46823 { "GLOBALRAMD", GLOBALRAMD, 0, 0 },
46824 { "LWPNHXOFS", LWPNHXOFS, 0, 0 },
46825 { "LWPNHYOFS", LWPNHYOFS, 0, 0 },
46826 { "LWPNXOFS", LWPNXOFS, 0, 0 },
46827 { "LWPNYOFS", LWPNYOFS, 0, 0 },
46828 { "LWPNZOFS", LWPNZOFS, 0, 0 },
46829 { "LWPNHXSZ", LWPNHXSZ, 0, 0 },
46830 { "LWPNHYSZ", LWPNHYSZ, 0, 0 },
46831 { "LWPNHZSZ", LWPNHZSZ, 0, 0 },
46832 { "EWPNHXOFS", EWPNHXOFS, 0, 0 },
46833 { "EWPNHYOFS", EWPNHYOFS, 0, 0 },
46834 { "EWPNXOFS", EWPNXOFS, 0, 0 },
46835 { "EWPNYOFS", EWPNYOFS, 0, 0 },
46836 { "EWPNZOFS", EWPNZOFS, 0, 0 },
46837 { "EWPNHXSZ", EWPNHXSZ, 0, 0 },
46838 { "EWPNHYSZ", EWPNHYSZ, 0, 0 },
46839 { "EWPNHZSZ", EWPNHZSZ, 0, 0 },
46840 { "NPCHXOFS", NPCHXOFS, 0, 0 },
46841 { "NPCHYOFS", NPCHYOFS, 0, 0 },
46842 { "NPCXOFS", NPCXOFS, 0, 0 },
46843 { "NPCYOFS", NPCYOFS, 0, 0 },
46844 { "NPCZOFS", NPCZOFS, 0, 0 },
46845 { "NPCHXSZ", NPCHXSZ, 0, 0 },
46846 { "NPCHYSZ", NPCHYSZ, 0, 0 },
46847 { "NPCHZSZ", NPCHZSZ, 0, 0 },
46848 { "ITEMHXOFS", ITEMHXOFS, 0, 0 },
46849 { "ITEMHYOFS", ITEMHYOFS, 0, 0 },
46850 { "ITEMXOFS", ITEMXOFS, 0, 0 },
46851 { "ITEMYOFS", ITEMYOFS, 0, 0 },
46852 { "ITEMZOFS", ITEMZOFS, 0, 0 },
46853 { "ITEMHXSZ", ITEMHXSZ, 0, 0 },
46854 { "ITEMHYSZ", ITEMHYSZ, 0, 0 },
46855 { "ITEMHZSZ", ITEMHZSZ, 0, 0 },
46856 { "LWPNTXSZ", LWPNTXSZ, 0, 0 },
46857 { "LWPNTYSZ", LWPNTYSZ, 0, 0 },
46858 { "EWPNTXSZ", EWPNTXSZ, 0, 0 },
46859 { "EWPNTYSZ", EWPNTYSZ, 0, 0 },
46860 { "NPCTXSZ", NPCTXSZ, 0, 0 },
46861 { "NPCTYSZ", NPCTYSZ, 0, 0 },
46862 { "ITEMTXSZ", ITEMTXSZ, 0, 0 },
46863 { "ITEMTYSZ", ITEMTYSZ, 0, 0 },
46864 { "LINKHXOFS", LINKHXOFS, 0, 0 },
46865 { "LINKHYOFS", LINKHYOFS, 0, 0 },
46866 { "LINKXOFS", LINKXOFS, 0, 0 },
46867 { "LINKYOFS", LINKYOFS, 0, 0 },
46868 { "LINKZOFS", LINKZOFS, 0, 0 },
46869 { "LINKHXSZ", LINKHXSZ, 0, 0 },
46870 { "LINKHYSZ", LINKHYSZ, 0, 0 },
46871 { "LINKHZSZ", LINKHZSZ, 0, 0 },
46872 { "LINKTXSZ", LINKTXSZ, 0, 0 },
46873 { "LINKTYSZ", LINKTYSZ, 0, 0 },
46874 { "NPCTILE", NPCTILE, 0, 0 },
46875 { "LWPNBEHIND", LWPNBEHIND, 0, 0 },
46876 { "EWPNBEHIND", EWPNBEHIND, 0, 0 },
46877 { "SDDDD", SDDDD, 0, 0 },
46878 { "CURLEVEL", CURLEVEL, 0, 0 },
46879 { "ITEMPICKUP", ITEMPICKUP, 0, 0 },
46880 { "INPUTMAP", INPUTMAP, 0, 0 },
46881 { "LIT", LIT, 0, 0 },
46882 { "INPUTEX1", INPUTEX1, 0, 0 },
46883 { "INPUTEX2", INPUTEX2, 0, 0 },
46884 { "INPUTEX3", INPUTEX3, 0, 0 },
46885 { "INPUTEX4", INPUTEX4, 0, 0 },
46886 { "INPUTPRESSSTART", INPUTPRESSSTART, 0, 0 },
46887 { "INPUTPRESSUP", INPUTPRESSUP, 0, 0 },
46888 { "INPUTPRESSDOWN", INPUTPRESSDOWN, 0, 0 },
46889 { "INPUTPRESSLEFT", INPUTPRESSLEFT, 0, 0 },
46890 { "INPUTPRESSRIGHT", INPUTPRESSRIGHT, 0, 0 },
46891 { "INPUTPRESSA", INPUTPRESSA, 0, 0 },
46892 { "INPUTPRESSB", INPUTPRESSB, 0, 0 },
46893 { "INPUTPRESSL", INPUTPRESSL, 0, 0 },
46894 { "INPUTPRESSR", INPUTPRESSR, 0, 0 },
46895 { "INPUTPRESSEX1", INPUTPRESSEX1, 0, 0 },
46896 { "INPUTPRESSEX2", INPUTPRESSEX2, 0, 0 },
46897 { "INPUTPRESSEX3", INPUTPRESSEX3, 0, 0 },
46898 { "INPUTPRESSEX4", INPUTPRESSEX4, 0, 0 },
46899 { "LWPNMISCD", LWPNMISCD, 0, 0 },
46900 { "EWPNMISCD", EWPNMISCD, 0, 0 },
46901 { "NPCMISCD", NPCMISCD, 0, 0 },
46902 { "ITEMMISCD", ITEMMISCD, 0, 0 },
46903 { "FFMISCD", FFMISCD, 0, 0 },
46904 { "GETMIDI", GETMIDI, 0, 0 },
46905 { "NPCHOMING", NPCHOMING, 0, 0 },
46906 { "NPCDD", NPCDD, 0, 0 },
46907 { "LINKEQUIP", LINKEQUIP, 0, 0 },
46908 { "INPUTAXISUP", INPUTAXISUP, 0, 0 },
46909 { "INPUTAXISDOWN", INPUTAXISDOWN, 0, 0 },
46910 { "INPUTAXISLEFT", INPUTAXISLEFT, 0, 0 },
46911 { "INPUTAXISRIGHT", INPUTAXISRIGHT, 0, 0 },
46912 { "PRESSAXISUP", INPUTPRESSAXISUP, 0, 0 },
46913 { "PRESSAXISDOWN", INPUTPRESSAXISDOWN, 0, 0 },
46914 { "PRESSAXISLEFT", INPUTPRESSAXISLEFT, 0, 0 },
46915 { "PRESSAXISRIGHT", INPUTPRESSAXISRIGHT, 0, 0 },
46916 { "NPCTYPE", NPCTYPE, 0, 0 },
46917 { "FFSCRIPT", FFSCRIPT, 0, 0 },
46918 { "SCREENFLAGSD", SCREENFLAGSD, 0, 0 },
46919 { "LINKINVIS", LINKINVIS, 0, 0 },
46920 { "LINKINVINC", LINKINVINC, 0, 0 },
46921 { "SCREENEFLAGSD", SCREENEFLAGSD, 0, 0 },
46922 { "NPCMFLAGS", NPCMFLAGS, 0, 0 },
46923 { "FFINITDD", FFINITDD, 0, 0 },
46924 { "LINKMISCD", LINKMISCD, 0, 0 },
46925 { "DMAPFLAGSD", DMAPFLAGSD, 0, 0 },
46926 { "LWPNCOLLDET", LWPNCOLLDET, 0, 0 },
46927 { "EWPNCOLLDET", EWPNCOLLDET, 0, 0 },
46928 { "NPCCOLLDET", NPCCOLLDET, 0, 0 },
46929 { "LINKLADDERX", LINKLADDERX, 0, 0 },
46930 { "LINKLADDERY", LINKLADDERY, 0, 0 },
46931 { "NPCSTUN", NPCSTUN, 0, 0 },
46932 { "NPCDEFENSED", NPCDEFENSED, 0, 0 },
46933 { "IDATAPOWER", IDATAPOWER, 0, 0 },
46934 { "DMAPLEVELD", DMAPLEVELD, 0, 0 },
46935 { "DMAPCOMPASSD", DMAPCOMPASSD, 0, 0 },
46936 { "DMAPCONTINUED", DMAPCONTINUED, 0, 0 },
46937 { "DMAPMIDID", DMAPMIDID, 0, 0 },
46938 { "IDATAINITDD", IDATAINITDD, 0, 0 },
46939 { "ROOMTYPE", ROOMTYPE, 0, 0 },
46940 { "ROOMDATA", ROOMDATA, 0, 0 },
46941 { "LINKTILE", LINKTILE, 0, 0 },
46942 { "LINKFLIP", LINKFLIP, 0, 0 },
46943 { "INPUTPRESSMAP", INPUTPRESSMAP, 0, 0 },
46944 { "NPCHUNGER", NPCHUNGER, 0, 0 },
46945 { "GAMESTANDALONE", GAMESTANDALONE, 0, 0 },
46946 { "GAMEENTRSCR", GAMEENTRSCR, 0, 0 },
46947 { "GAMEENTRDMAP", GAMEENTRDMAP, 0, 0 },
46948 { "GAMECLICKFREEZE", GAMECLICKFREEZE, 0, 0 },
46949 { "PUSHBLOCKX", PUSHBLOCKX, 0, 0 },
46950 { "PUSHBLOCKY", PUSHBLOCKY, 0, 0 },
46951 { "PUSHBLOCKCOMBO", PUSHBLOCKCOMBO, 0, 0 },
46952 { "PUSHBLOCKCSET", PUSHBLOCKCSET, 0, 0 },
46953 { "UNDERCOMBO", UNDERCOMBO, 0, 0 },
46954 { "UNDERCSET", UNDERCSET, 0, 0 },
46955 { "DMAPOFFSET", DMAPOFFSET, 0, 0 },
46956 { "DMAPMAP", DMAPMAP, 0, 0 },
46957 { "__RESERVED_FOR_GAMETHROTTLE", __RESERVED_FOR_GAMETHROTTLE, 0, 0 },
46958 { "REFMAPDATA", REFMAPDATA, 0, 0 },
46959 { "REFSCREENDATA", REFSCREENDATA, 0, 0 },
46960 { "REFCOMBODATA", REFCOMBODATA, 0, 0 },
46961 { "REFSPRITEDATA", REFSPRITEDATA, 0, 0 },
46962 { "REFBITMAP", REFBITMAP, 0, 0 },
46963 { "REFDMAPDATA", REFDMAPDATA, 0, 0 },
46964 { "REFSHOPDATA", REFSHOPDATA, 0, 0 },
46965 { "REFMSGDATA", REFMSGDATA, 0, 0 },
46966 { "REFUNTYPED", REFUNTYPED, 0, 0 },
46967 { "REFDROPS", REFDROPS, 0, 0 },
46968 { "REFPONDS", REFPONDS, 0, 0 },
46969 { "REFWARPRINGS", REFWARPRINGS, 0, 0 },
46970 { "REFDOORS", REFDOORS, 0, 0 },
46971 { "REFUICOLOURS", REFUICOLOURS, 0, 0 },
46972 { "REFRGB", REFRGB, 0, 0 },
46973 { "REFPALETTE", REFPALETTE, 0, 0 },
46974 { "REFTUNES", REFTUNES, 0, 0 },
46975 { "REFPALCYCLE", REFPALCYCLE, 0, 0 },
46976 { "REFGAMEDATA", REFGAMEDATA, 0, 0 },
46977 { "REFCHEATS", REFCHEATS, 0, 0 },
46978 { "IDATAMAGICTIMER", IDATAMAGICTIMER, 0, 0 },
46979 { "IDATALTM", IDATALTM, 0, 0 },
46980 { "IDATASCRIPT", IDATASCRIPT, 0, 0 },
46981 { "IDATAPSCRIPT", IDATAPSCRIPT, 0, 0 },
46982 { "IDATAMAGCOST", IDATAMAGCOST, 0, 0 },
46983 { "IDATAMINHEARTS", IDATAMINHEARTS, 0, 0 },
46984 { "IDATATILE", IDATATILE, 0, 0 },
46985 { "IDATAMISC", IDATAMISC, 0, 0 },
46986 { "IDATACSET", IDATACSET, 0, 0 },
46987 { "IDATAFRAMES", IDATAFRAMES, 0, 0 },
46988 { "IDATAASPEED", IDATAASPEED, 0, 0 },
46989 { "IDATADELAY", IDATADELAY, 0, 0 },
46990 { "IDATACOMBINE", IDATACOMBINE, 0, 0 },
46991 { "IDATADOWNGRADE", IDATADOWNGRADE, 0, 0 },
46992 { "IDATAPSTRING", IDATAPSTRING, 0, 0 },
46993 { "IDATAPFLAGS", IDATAPFLAGS, 0, 0 },
46994 { "IDATAKEEPOLD", IDATAKEEPOLD, 0, 0 },
46995 { "IDATARUPEECOST", IDATARUPEECOST, 0, 0 },
46996 { "IDATAEDIBLE", IDATAEDIBLE, 0, 0 },
46997 { "IDATAFLAGUNUSED", IDATAFLAGUNUSED, 0, 0 },
46998 { "IDATAGAINLOWER", IDATAGAINLOWER, 0, 0 },
46999 { "RESVD0024", RESVD024, 0, 0 },
47000 { "RESVD0025", RESVD025, 0, 0 },
47001 { "RESVD0026", RESVD026, 0, 0 },
47002 { "IDATAID", IDATAID, 0, 0 },
47003 { "__RESERVED_FOR_LINKEXTEND", __RESERVED_FOR_LINKEXTEND, 0, 0 },
47004 { "NPCSCRDEFENSED", NPCSCRDEFENSED, 0, 0 },
47005 { "__RESERVED_FOR_SETLINKTILE", __RESERVED_FOR_SETLINKTILE, 0, 0 },
47006 { "__RESERVED_FOR_SETLINKEXTEND", __RESERVED_FOR_SETLINKEXTEND, 0, 0 },
47007 { "__RESERVED_FOR_SIDEWARPSFX", __RESERVED_FOR_SIDEWARPSFX, 0, 0 },
47008 { "__RESERVED_FOR_PITWARPSFX", __RESERVED_FOR_PITWARPSFX, 0, 0 },
47009 { "__RESERVED_FOR_SIDEWARPVISUAL", __RESERVED_FOR_SIDEWARPVISUAL, 0, 0 },
47010 { "__RESERVED_FOR_PITWARPVISUAL", __RESERVED_FOR_PITWARPVISUAL, 0, 0 },
47011 { "GAMESETA", GAMESETA, 0, 0 },
47012 { "GAMESETB", GAMESETB, 0, 0 },
47013 { "SETITEMSLOT", SETITEMSLOT, 0, 0 },
47014 { "LINKITEMB", LINKITEMB, 0, 0 },
47015 { "LINKITEMA", LINKITEMA, 0, 0 },
47016 { "__RESERVED_FOR_LINKWALKTILE", __RESERVED_FOR_LINKWALKTILE, 0, 0 }, //Walk sprite
47017 { "__RESERVED_FOR_LINKFLOATTILE", __RESERVED_FOR_LINKFLOATTILE, 0, 0 }, //float sprite
47018 { "__RESERVED_FOR_LINKSWIMTILE", __RESERVED_FOR_LINKSWIMTILE, 0, 0 }, //swim sprite
47019 { "__RESERVED_FOR_LINKDIVETILE", __RESERVED_FOR_LINKDIVETILE, 0, 0 }, //dive sprite
47020 { "__RESERVED_FOR_LINKSLASHTILE", __RESERVED_FOR_LINKSLASHTILE, 0, 0 }, //slash sprite
47021 { "__RESERVED_FOR_LINKJUMPTILE", __RESERVED_FOR_LINKJUMPTILE, 0, 0 }, //jump sprite
47022 { "__RESERVED_FOR_LINKCHARGETILE", __RESERVED_FOR_LINKCHARGETILE, 0, 0 }, //charge sprite
47023 { "__RESERVED_FOR_LINKSTABTILE", __RESERVED_FOR_LINKSTABTILE, 0, 0 }, //stab sprite
47024 { "__RESERVED_FOR_LINKCASTTILE", __RESERVED_FOR_LINKCASTTILE, 0, 0 }, //casting sprite
47025 { "__RESERVED_FOR_LINKHOLD1LTILE", __RESERVED_FOR_LINKHOLD1LTILE, 0, 0 }, //hold1land sprite
47026 { "__RESERVED_FOR_LINKHOLD2LTILE", __RESERVED_FOR_LINKHOLD2LTILE, 0, 0 }, //hold2land sprite
47027 { "__RESERVED_FOR_LINKHOLD1WTILE", __RESERVED_FOR_LINKHOLD1WTILE, 0, 0 }, //hold1water sprite
47028 { "__RESERVED_FOR_LINKHOLD2WTILE", __RESERVED_FOR_LINKHOLD2WTILE, 0, 0 }, //hold2water sprite
47029 { "__RESERVED_FOR_LINKPOUNDTILE", __RESERVED_FOR_LINKPOUNDTILE, 0, 0 }, //hammer pound sprite
47030 { "__RESERVED_FOR_LINKSWIMSPD", __RESERVED_FOR_LINKSWIMSPD, 0, 0 },
47031 { "__RESERVED_FOR_LINKWALKANMSPD", __RESERVED_FOR_LINKWALKANMSPD, 0, 0 },
47032 { "__RESERVED_FOR_LINKANIMTYPE", __RESERVED_FOR_LINKANIMTYPE, 0, 0 },
47033 { "LINKINVFRAME", LINKINVFRAME, 0, 0 },
47034 { "LINKCANFLICKER", LINKCANFLICKER, 0, 0 },
47035 { "LINKHURTSFX", LINKHURTSFX, 0, 0 },
47036 { "NOACTIVESUBSC", NOACTIVESUBSC, 0, 0 },
47037 { "LWPNRANGE", LWPNRANGE, 0, 0 },
47038 { "ZELDAVERSION", ZELDAVERSION, 0, 0 },
47039 { "ZELDABUILD", ZELDABUILD, 0, 0 },
47040 { "ZELDABETA", ZELDABETA, 0, 0 },
47041 { "NPCINVINC", NPCINVINC, 0, 0 },
47042 { "NPCSUPERMAN", NPCSUPERMAN, 0, 0 },
47043 { "NPCHASITEM", NPCHASITEM, 0, 0 },
47044 { "NPCRINGLEAD", NPCRINGLEAD, 0, 0 },
47045 { "IDATAFRAME", IDATAFRAME, 0, 0 },
47046 { "ITEMACLK", ITEMACLK, 0, 0 },
47047 { "FFCID", FFCID, 0, 0 },
47048 { "IDATAATTRIB", IDATAATTRIB, 0, 0 },
47049 { "IDATASPRITE", IDATASPRITE, 0, 0 },
47050 { "IDATAFLAGS", IDATAFLAGS, 0, 0 },
47051 { "DMAPLEVELPAL", DMAPLEVELPAL, 0, 0 },
47052 { "__RESERVED_FOR_ITEMPTR", __RESERVED_FOR_ITEMPTR, 0, 0 },
47053 { "__RESERVED_FOR_NPCPTR", __RESERVED_FOR_NPCPTR, 0, 0 },
47054 { "__RESERVED_FOR_LWPNPTR", __RESERVED_FOR_LWPNPTR, 0, 0 },
47055 { "__RESERVED_FOR_EWPNPTR", __RESERVED_FOR_EWPNPTR, 0, 0 },
47056 { "SETSCREENDOOR", SETSCREENDOOR, 0, 0 },
47057 { "SETSCREENENEMY", SETSCREENENEMY, 0, 0 },
47058 { "GAMEMAXMAPS", GAMEMAXMAPS, 0, 0 },
47059 { "CREATELWPNDX", CREATELWPNDX, 0, 0 },
47060 { "__RESERVED_FOR_SCREENFLAG", __RESERVED_FOR_SCREENFLAG, 0, 0 },
47061 { "BUTTONPRESS", BUTTONPRESS, 0, 0 },
47062 { "BUTTONINPUT", BUTTONINPUT, 0, 0 },
47063 { "BUTTONHELD", BUTTONHELD, 0, 0 },
47064 { "RAWKEY", RAWKEY, 0, 0 },
47065 { "READKEY", READKEY, 0, 0 },
47066 { "JOYPADPRESS", JOYPADPRESS, 0, 0 },
47067 { "DISABLEDITEM", DISABLEDITEM, 0, 0 },
47068 { "LINKDIAG", LINKDIAG, 0, 0 },
47069 { "LINKBIGHITBOX", LINKBIGHITBOX, 0, 0 },
47070 { "LINKEATEN", LINKEATEN, 0, 0 },
47071 { "__RESERVED_FOR_LINKRETSQUARE", __RESERVED_FOR_LINKRETSQUARE, 0, 0 },
47072 { "__RESERVED_FOR_LINKWARPSOUND", __RESERVED_FOR_LINKWARPSOUND, 0, 0 },
47073 { "__RESERVED_FOR_PLAYPITWARPSFX", __RESERVED_FOR_PLAYPITWARPSFX, 0, 0 },
47074 { "__RESERVED_FOR_WARPEFFECT", __RESERVED_FOR_WARPEFFECT, 0, 0 },
47075 { "__RESERVED_FOR_PLAYWARPSOUND", __RESERVED_FOR_PLAYWARPSOUND, 0, 0 },
47076 { "LINKUSINGITEM", LINKUSINGITEM, 0, 0 },
47077 { "LINKUSINGITEMA", LINKUSINGITEMA, 0, 0 },
47078 { "LINKUSINGITEMB", LINKUSINGITEMB, 0, 0 },
47079 // { "DMAPLEVELPAL", DMAPLEVELPAL, 0, 0 },
47080 // { "LINKZHEIGHT", LINKZHEIGHT, 0, 0 },
47081 // { "ITEMINDEX", ITEMINDEX, 0, 0 },
47082 // { "LWPNINDEX", LWPNINDEX, 0, 0 },
47083 // { "EWPNINDEX", EWPNINDEX, 0, 0 },
47084 // { "NPCINDEX", NPCINDEX, 0, 0 },
47085 //TABLE END
47086 { "IDATAUSEWPN", IDATAUSEWPN, 0, 0 }, //UseWeapon
47087 { "IDATAUSEDEF", IDATAUSEDEF, 0, 0 }, //UseDefense
47088 { "IDATAWRANGE", IDATAWRANGE, 0, 0 }, //Range
47089 { "IDATAUSEMVT", IDATAUSEMVT, 0, 0 }, //Movement[]
47090 { "IDATADURATION", IDATADURATION, 0, 0 }, //Duration
47091
47092 { "IDATADUPLICATES", IDATADUPLICATES, 0, 0 }, //Duplicates
47093 { "IDATADRAWLAYER", IDATADRAWLAYER, 0, 0 }, //DrawLayer
47094 { "IDATACOLLECTFLAGS", IDATACOLLECTFLAGS, 0, 0 }, //CollectFlags
47095 { "IDATAWEAPONSCRIPT", IDATAWEAPONSCRIPT, 0, 0 }, //WeaponScript
47096 { "IDATAMISCD", IDATAMISCD, 0, 0 }, //WeaponMisc[32]
47097 { "IDATAWEAPHXOFS", IDATAWEAPHXOFS, 0, 0 }, //WeaponHitXOffset
47098 { "IDATAWEAPHYOFS", IDATAWEAPHYOFS, 0, 0 }, //WeaponHitYOffset
47099 { "IDATAWEAPHXSZ", IDATAWEAPHYSZ, 0, 0 }, //WeaponHitWidth
47100 { "IDATAWEAPHYSZ", IDATAWEAPHYSZ, 0, 0 }, //WeaponHitHeight
47101 { "IDATAWEAPHZSZ", IDATAWEAPHZSZ, 0, 0 }, //WeaponHitZHeight
47102 { "IDATAWEAPXOFS", IDATAWEAPXOFS, 0, 0 }, //WeaponDrawXOffset
47103 { "IDATAWEAPYOFS", IDATAWEAPYOFS, 0, 0 }, //WeaponDrawYOffset
47104 { "IDATAWEAPZOFS", IDATAWEAPZOFS, 0, 0 }, //WeaponDrawZOffset
47105 { "IDATAWPNINITD", IDATAWPNINITD, 0, 0 }, //WeaponD[8]
47106
47107 { "NPCWEAPSPRITE", NPCWEAPSPRITE, 0, 0 }, //WeaponSprite
47108
47109 { "DEBUGREFFFC", DEBUGREFFFC, 0, 0 }, //REFFFC
47110 { "DEBUGREFITEM", DEBUGREFITEM, 0, 0 }, //REFITEM
47111 { "DEBUGREFNPC", DEBUGREFNPC, 0, 0 }, //REFNPC
47112 { "DEBUGREFITEMDATA", DEBUGREFITEMDATA, 0, 0 }, //REFITEMCLASS
47113 { "DEBUGREFLWEAPON", DEBUGREFLWEAPON, 0, 0 }, //REFLWPN
47114 { "DEBUGREFEWEAPON", DEBUGREFEWEAPON, 0, 0 }, //REFEWPN
47115 { "DEBUGSP", DEBUGSP, 0, 0 }, //SP
47116 { "DEBUGGDR", DEBUGGDR, 0, 0 }, //GDR[256]
47117 { "SCREENWIDTH", SCREENWIDTH, 0, 0 },
47118 { "SCREENHEIGHT", SCREENHEIGHT, 0, 0 },
47119 { "SCREENVIEWX", SCREENVIEWX, 0, 0 },
47120 { "SCREENVIEWY", SCREENVIEWY, 0, 0 },
47121 { "SCREENGUY", SCREENGUY, 0, 0 },
47122 { "SCREENSTRING", SCREENSTRING, 0, 0 },
47123 { "SCREENROOM", SCREENROOM, 0, 0 },
47124 { "SCREENENTX", SCREENENTX, 0, 0 },
47125 { "SCREENENTY", SCREENENTY, 0, 0 },
47126 { "SCREENITEM", SCREENITEM, 0, 0 },
47127 { "SCREENUNDCMB", SCREENUNDCMB, 0, 0 },
47128 { "SCREENUNDCST", SCREENUNDCST, 0, 0 },
47129 { "SCREENCATCH", SCREENCATCH, 0, 0 },
47130 { "SETSCREENLAYOP", SETSCREENLAYOP, 0, 0 },
47131 { "SETSCREENSECCMB", SETSCREENSECCMB, 0, 0 },
47132 { "SETSCREENSECCST", SETSCREENSECCST, 0, 0 },
47133 { "SETSCREENSECFLG", SETSCREENSECFLG, 0, 0 },
47134 { "SETSCREENLAYMAP", SETSCREENLAYMAP, 0, 0 },
47135 { "SETSCREENLAYSCR", SETSCREENLAYSCR, 0, 0 },
47136 { "SETSCREENPATH", SETSCREENPATH, 0, 0 },
47137 { "SETSCREENWARPRX", SETSCREENWARPRX, 0, 0 },
47138 { "SETSCREENWARPRY", SETSCREENWARPRY, 0, 0 },
47139 {"GAMENUMMESSAGES", GAMENUMMESSAGES, 0, 0 },
47140 {"GAMESUBSCHEIGHT", GAMESUBSCHEIGHT, 0, 0 },
47141 {"GAMEPLAYFIELDOFS", GAMEPLAYFIELDOFS, 0, 0 },
47142 {"PASSSUBOFS", PASSSUBOFS, 0, 0 }, //
47143
47144
47145 //NPCData
47146 {"SETNPCDATASCRIPTDEF", SETNPCDATASCRIPTDEF, 0, 0 },
47147 {"SETNPCDATADEFENSE", SETNPCDATADEFENSE, 0, 0 },
47148 {"SETNPCDATASIZEFLAG", SETNPCDATASIZEFLAG, 0, 0 },
47149 {"SETNPCDATAATTRIBUTE", SETNPCDATAATTRIBUTE, 0, 0 },
47150
47151 {"SCDBLOCKWEAPON", SCDBLOCKWEAPON, 0, 0 },
47152 {"SCDSTRIKEWEAPONS", SCDSTRIKEWEAPONS, 0, 0 },
47153 {"SCDEXPANSION", SCDEXPANSION, 0, 0 },
47154 {"SETGAMEOVERELEMENT", SETGAMEOVERELEMENT, 0, 0 },
47155 {"SETGAMEOVERSTRING", SETGAMEOVERSTRING, 0, 0 },
47156 {"MOUSEARR", MOUSEARR, 0, 0 },
47157
47158 {"IDATAOVERRIDEFLWEAP", IDATAOVERRIDEFLWEAP, 0, 0 },
47159 {"IDATATILEHWEAP", IDATATILEHWEAP, 0, 0 },
47160 {"IDATATILEWWEAP", IDATATILEWWEAP, 0, 0 },
47161 {"IDATAHZSZWEAP", IDATAHZSZWEAP, 0, 0 },
47162 {"IDATAHYSZWEAP", IDATAHYSZWEAP, 0, 0 },
47163 {"IDATAHXSZWEAP", IDATAHXSZWEAP, 0, 0 },
47164 {"IDATADYOFSWEAP", IDATADYOFSWEAP, 0, 0 },
47165 {"IDATADXOFSWEAP", IDATADXOFSWEAP, 0, 0 },
47166 {"IDATAHYOFSWEAP", IDATAHYOFSWEAP, 0, 0 },
47167 {"IDATAHXOFSWEAP", IDATAHXOFSWEAP, 0, 0 },
47168 {"IDATAOVERRIDEFL", IDATAOVERRIDEFL, 0, 0 },
47169 {"IDATAPICKUP", IDATAPICKUP, 0, 0 },
47170 {"IDATATILEH", IDATATILEH, 0, 0 },
47171 {"IDATATILEW", IDATATILEW, 0, 0 },
47172 {"IDATAHZSZ", IDATAHZSZ, 0, 0 },
47173 {"IDATAHYSZ", IDATAHYSZ, 0, 0 },
47174 {"IDATAHXSZ", IDATAHXSZ, 0, 0 },
47175 {"IDATADYOFS", IDATADYOFS, 0, 0 },
47176 {"IDATADXOFS", IDATADXOFS, 0, 0 },
47177 {"IDATAHYOFS", IDATAHYOFS, 0, 0 },
47178 {"IDATAHXOFS", IDATAHXOFS, 0, 0 },
47179 //spritedata sd->
47180 {"SPRITEDATATILE", SPRITEDATATILE, 0, 0 },
47181 {"SPRITEDATAMISC", SPRITEDATAMISC, 0, 0 },
47182 {"SPRITEDATACSETS", SPRITEDATACSETS, 0, 0 },
47183 {"SPRITEDATAFRAMES", SPRITEDATAFRAMES, 0, 0 },
47184 {"SPRITEDATASPEED", SPRITEDATASPEED, 0, 0 },
47185 {"SPRITEDATATYPE", SPRITEDATATYPE, 0, 0 },
47186
47187 //npcdata nd->
47188 {"NPCDATATILE", NPCDATATILE, 0, 0 },
47189 {"NPCDATAHEIGHT", NPCDATAHEIGHT, 0, 0 },
47190 {"NPCDATAFLAGS", NPCDATAFLAGS, 0, 0 },
47191 {"NPCDATAFLAGS2", NPCDATAFLAGS2, 0, 0 },
47192 {"NPCDATAWIDTH", NPCDATAWIDTH, 0, 0 },
47193 {"NPCDATAHITSFX", NPCDATAHITSFX, 0, 0 },
47194 {"NPCDATASTILE", NPCDATASTILE, 0, 0 },
47195 {"NPCDATASWIDTH", NPCDATASWIDTH, 0, 0 },
47196 {"NPCDATASHEIGHT", NPCDATASHEIGHT, 0, 0 },
47197 {"NPCDATAETILE", NPCDATAETILE, 0, 0 },
47198 {"NPCDATAEWIDTH", NPCDATAEWIDTH, 0, 0 },
47199 {"NPCDATAEHEIGHT", NPCDATAEHEIGHT, 0, 0 },
47200 {"NPCDATAHP", NPCDATAHP, 0, 0 },
47201 {"NPCDATAFAMILY", NPCDATAFAMILY, 0, 0 },
47202 {"NPCDATACSET", NPCDATACSET, 0, 0 },
47203 {"NPCDATAANIM", NPCDATAANIM, 0, 0 },
47204 {"NPCDATAEANIM", NPCDATAEANIM, 0, 0 },
47205 {"NPCDATAFRAMERATE", NPCDATAFRAMERATE, 0, 0 },
47206 {"NPCDATAEFRAMERATE", NPCDATAEFRAMERATE, 0, 0 },
47207 {"NPCDATATOUCHDAMAGE", NPCDATATOUCHDAMAGE, 0, 0 },
47208 {"NPCDATAWEAPONDAMAGE", NPCDATAWEAPONDAMAGE, 0, 0 },
47209 {"NPCDATAWEAPON", NPCDATAWEAPON, 0, 0 },
47210 {"NPCDATARANDOM", NPCDATARANDOM, 0, 0 },
47211 {"NPCDATAHALT", NPCDATAHALT, 0, 0 },
47212 {"NPCDATASTEP", NPCDATASTEP, 0, 0 },
47213 {"NPCDATAHOMING", NPCDATAHOMING, 0, 0 },
47214 {"NPCDATAHUNGER", NPCDATAHUNGER, 0, 0 },
47215 {"NPCDATADROPSET", NPCDATADROPSET, 0, 0 },
47216 {"NPCDATABGSFX", NPCDATABGSFX, 0, 0 },
47217 {"NPCDATADEATHSFX", NPCDATADEATHSFX, 0, 0 },
47218 {"NPCDATAXOFS", NPCDATAXOFS, 0, 0 },
47219 {"NPCDATAYOFS", NPCDATAYOFS, 0, 0 },
47220 {"NPCDATAZOFS", NPCDATAZOFS, 0, 0 },
47221 {"NPCDATAHXOFS", NPCDATAHXOFS, 0, 0 },
47222 {"NPCDATAHYOFS", NPCDATAHYOFS, 0, 0 },
47223 {"NPCDATAHITWIDTH", NPCDATAHITWIDTH, 0, 0 },
47224 {"NPCDATAHITHEIGHT", NPCDATAHITHEIGHT, 0, 0 },
47225 {"NPCDATAHITZ", NPCDATAHITZ, 0, 0 },
47226 {"NPCDATATILEWIDTH", NPCDATATILEWIDTH, 0, 0 },
47227 {"NPCDATATILEHEIGHT", NPCDATATILEHEIGHT, 0, 0 },
47228 {"NPCDATAWPNSPRITE", NPCDATAWPNSPRITE, 0, 0 },
47229 {"NPCDATADEFENSE", NPCDATADEFENSE, 0, 0 },
47230 {"NPCDATASIZEFLAG", NPCDATASIZEFLAG, 0, 0 },
47231 {"NPCDATAATTRIBUTE", NPCDATAATTRIBUTE, 0, 0 },
47232
47233 {"NPCDATAFROZENTILE", NPCDATAFROZENTILE, 0, 0 },
47234 {"NPCDATAFROZENCSET", NPCDATAFROZENCSET, 0, 0 },
47235
47236 //mapdata md->
47237 {"MAPDATAVALID", MAPDATAVALID, 0, 0 },
47238 {"MAPDATAGUY", MAPDATAGUY, 0, 0 },
47239 {"MAPDATASTRING", MAPDATASTRING, 0, 0 },
47240 {"MAPDATAROOM", MAPDATAROOM, 0, 0 },
47241 {"MAPDATAITEM", MAPDATAITEM, 0, 0 },
47242 {"MAPDATAHASITEM", MAPDATAHASITEM, 0, 0 },
47243 {"MAPDATATILEWARPTYPE", MAPDATATILEWARPTYPE, 0, 0 },
47244 {"MAPDATATILEWARPOVFLAGS", MAPDATATILEWARPOVFLAGS, 0, 0 },
47245 {"MAPDATADOORCOMBOSET", MAPDATADOORCOMBOSET, 0, 0 },
47246 {"MAPDATAWARPRETX", MAPDATAWARPRETX, 0, 0 },
47247 {"MAPDATAWARPRETY", MAPDATAWARPRETY, 0, 0 },
47248 {"MAPDATAWARPRETURNC", MAPDATAWARPRETURNC, 0, 0 },
47249 {"MAPDATASTAIRX", MAPDATASTAIRX, 0, 0 },
47250 {"MAPDATASTAIRY", MAPDATASTAIRY, 0, 0 },
47251 {"MAPDATACOLOUR", MAPDATACOLOUR, 0, 0 },
47252 {"MAPDATAENEMYFLAGS", MAPDATAENEMYFLAGS, 0, 0 },
47253 {"MAPDATADOOR", MAPDATADOOR, 0, 0 },
47254 {"MAPDATATILEWARPDMAP", MAPDATATILEWARPDMAP, 0, 0 },
47255 {"MAPDATATILEWARPSCREEN", MAPDATATILEWARPSCREEN, 0, 0 },
47256 {"MAPDATAEXITDIR", MAPDATAEXITDIR, 0, 0 },
47257 {"MAPDATAENEMY", MAPDATAENEMY, 0, 0 },
47258 {"MAPDATAPATTERN", MAPDATAPATTERN, 0, 0 },
47259 {"MAPDATASIDEWARPTYPE", MAPDATASIDEWARPTYPE, 0, 0 },
47260 {"MAPDATASIDEWARPOVFLAGS", MAPDATASIDEWARPOVFLAGS, 0, 0 },
47261 {"MAPDATAWARPARRIVALX", MAPDATAWARPARRIVALX, 0, 0 },
47262 {"MAPDATAWARPARRIVALY", MAPDATAWARPARRIVALY, 0, 0 },
47263 {"MAPDATAPATH", MAPDATAPATH, 0, 0 },
47264 {"MAPDATASIDEWARPSC", MAPDATASIDEWARPSC, 0, 0 },
47265 {"MAPDATASIDEWARPDMAP", MAPDATASIDEWARPDMAP, 0, 0 },
47266 {"MAPDATASIDEWARPINDEX", MAPDATASIDEWARPINDEX, 0, 0 },
47267 {"MAPDATAUNDERCOMBO", MAPDATAUNDERCOMBO, 0, 0 },
47268 {"MAPDATAUNDERCSET", MAPDATAUNDERCSET, 0, 0 },
47269 {"MAPDATACATCHALL", MAPDATACATCHALL, 0, 0 },
47270 {"MAPDATAFLAGS", MAPDATAFLAGS, 0, 0 },
47271 {"MAPDATACSENSITIVE", MAPDATACSENSITIVE, 0, 0 },
47272 {"MAPDATANORESET", MAPDATANORESET, 0, 0 },
47273 {"MAPDATANOCARRY", MAPDATANOCARRY, 0, 0 },
47274 {"MAPDATALAYERMAP", MAPDATALAYERMAP, 0, 0 },
47275 {"MAPDATALAYERSCREEN", MAPDATALAYERSCREEN, 0, 0 },
47276 {"MAPDATALAYEROPACITY", MAPDATALAYEROPACITY, 0, 0 },
47277 {"MAPDATATIMEDWARPTICS", MAPDATATIMEDWARPTICS, 0, 0 },
47278 {"MAPDATANEXTMAP", MAPDATANEXTMAP, 0, 0 },
47279 {"MAPDATANEXTSCREEN", MAPDATANEXTSCREEN, 0, 0 },
47280 {"MAPDATASECRETCOMBO", MAPDATASECRETCOMBO, 0, 0 },
47281 {"MAPDATASECRETCSET", MAPDATASECRETCSET, 0, 0 },
47282 {"MAPDATASECRETFLAG", MAPDATASECRETFLAG, 0, 0 },
47283 {"MAPDATAVIEWX", MAPDATAVIEWX, 0, 0 },
47284 {"MAPDATAVIEWY", MAPDATAVIEWY, 0, 0 },
47285 {"MAPDATASCREENWIDTH", MAPDATASCREENWIDTH, 0, 0 },
47286 {"MAPDATASCREENHEIGHT", MAPDATASCREENHEIGHT, 0, 0 },
47287 {"MAPDATAENTRYX", MAPDATAENTRYX, 0, 0 },
47288 {"MAPDATAENTRYY", MAPDATAENTRYY, 0, 0 },
47289 {"MAPDATANUMFF", MAPDATANUMFF, 0, 0 },
47290 {"MAPDATAFFDATA", MAPDATAFFDATA, 0, 0 },
47291 {"MAPDATAFFCSET", MAPDATAFFCSET, 0, 0 },
47292 {"MAPDATAFFDELAY", MAPDATAFFDELAY, 0, 0 },
47293 {"MAPDATAFFX", MAPDATAFFX, 0, 0 },
47294 {"MAPDATAFFY", MAPDATAFFY, 0, 0 },
47295 {"MAPDATAFFXDELTA", MAPDATAFFXDELTA, 0, 0 },
47296 {"MAPDATAFFYDELTA", MAPDATAFFYDELTA, 0, 0 },
47297 {"MAPDATAFFXDELTA2", MAPDATAFFXDELTA2, 0, 0 },
47298 {"MAPDATAFFYDELTA2", MAPDATAFFYDELTA2, 0, 0 },
47299 {"MAPDATAFFFLAGS", MAPDATAFFFLAGS, 0, 0 },
47300 {"MAPDATAFFWIDTH", MAPDATAFFWIDTH, 0, 0 },
47301 {"MAPDATAFFHEIGHT", MAPDATAFFHEIGHT, 0, 0 },
47302 {"MAPDATAFFLINK", MAPDATAFFLINK, 0, 0 },
47303 {"MAPDATAFFSCRIPT", MAPDATAFFSCRIPT, 0, 0 },
47304 {"MAPDATAINTID", MAPDATAINTID, 0, 0 }, //Needs to be a function [32][10]
47305 {"MAPDATAINITA", MAPDATAINITA, 0, 0 }, //needs to be a function, [32][2]
47306 {"MAPDATAFFINITIALISED", MAPDATAFFINITIALISED, 0, 0 },
47307 {"MAPDATASCRIPTENTRY", MAPDATASCRIPTENTRY, 0, 0 },
47308 {"MAPDATASCRIPTOCCUPANCY", MAPDATASCRIPTOCCUPANCY, 0, 0 },
47309 {"MAPDATASCRIPTEXIT", MAPDATASCRIPTEXIT, 0, 0 },
47310 {"MAPDATAOCEANSFX", MAPDATAOCEANSFX, 0, 0 },
47311 {"MAPDATABOSSSFX", MAPDATABOSSSFX, 0, 0 },
47312 {"MAPDATASECRETSFX", MAPDATASECRETSFX, 0, 0 },
47313 {"MAPDATAHOLDUPSFX", MAPDATAHOLDUPSFX, 0, 0 },
47314 {"MAPDATASCREENMIDI", MAPDATASCREENMIDI, 0, 0 },
47315 {"MAPDATALENSLAYER", MAPDATALENSLAYER, 0, 0 },
47316 {"MAPDATAMISCD", MAPDATAMISCD, 0, 0},
47317
47318 {"MAPDATASCREENSTATED", MAPDATASCREENSTATED, 0, 0},
47319 {"MAPDATASCREENFLAGSD", MAPDATASCREENFLAGSD, 0, 0},
47320 {"MAPDATASCREENEFLAGSD", MAPDATASCREENEFLAGSD, 0, 0},
47321
47322
47323
47324 {"MAPDATACOMBODD", MAPDATACOMBODD, 0, 0},
47325 {"MAPDATACOMBOCD", MAPDATACOMBOCD, 0, 0},
47326 {"MAPDATACOMBOFD", MAPDATACOMBOFD, 0, 0},
47327 {"MAPDATACOMBOTD", MAPDATACOMBOTD, 0, 0},
47328 {"MAPDATACOMBOID", MAPDATACOMBOID, 0, 0},
47329 {"MAPDATACOMBOSD", MAPDATACOMBOSD, 0, 0},
47330
47331 {"SCREENDATAVALID", SCREENDATAVALID, 0, 0 },
47332 {"SCREENDATAGUY", SCREENDATAGUY, 0, 0 },
47333 {"SCREENDATASTRING", SCREENDATASTRING, 0, 0 },
47334 {"SCREENDATAROOM", SCREENDATAROOM, 0, 0 },
47335 {"SCREENDATAITEM", SCREENDATAITEM, 0, 0 },
47336 {"SCREENDATAHASITEM", SCREENDATAHASITEM, 0, 0 },
47337 {"SCREENDATATILEWARPTYPE", SCREENDATATILEWARPTYPE, 0, 0 },
47338 {"SCREENDATATILEWARPOVFLAGS", SCREENDATATILEWARPOVFLAGS, 0, 0 },
47339 {"SCREENDATADOORCOMBOSET", SCREENDATADOORCOMBOSET, 0, 0 },
47340 {"SCREENDATAWARPRETX", SCREENDATAWARPRETX, 0, 0 },
47341 {"SCREENDATAWARPRETY", SCREENDATAWARPRETY, 0, 0 },
47342 {"SCREENDATAWARPRETURNC", SCREENDATAWARPRETURNC, 0, 0 },
47343 {"SCREENDATASTAIRX", SCREENDATASTAIRX, 0, 0 },
47344 {"SCREENDATASTAIRY", SCREENDATASTAIRY, 0, 0 },
47345 {"SCREENDATACOLOUR", SCREENDATACOLOUR, 0, 0 },
47346 {"SCREENDATAENEMYFLAGS", SCREENDATAENEMYFLAGS, 0, 0 },
47347 {"SCREENDATADOOR", SCREENDATADOOR, 0, 0 },
47348 {"SCREENDATATILEWARPDMAP", SCREENDATATILEWARPDMAP, 0, 0 },
47349 {"SCREENDATATILEWARPSCREEN", SCREENDATATILEWARPSCREEN, 0, 0 },
47350 {"SCREENDATAEXITDIR", SCREENDATAEXITDIR, 0, 0 },
47351 {"SCREENDATAENEMY", SCREENDATAENEMY, 0, 0 },
47352 {"SCREENDATAPATTERN", SCREENDATAPATTERN, 0, 0 },
47353 {"SCREENDATASIDEWARPTYPE", SCREENDATASIDEWARPTYPE, 0, 0 },
47354 {"SCREENDATASIDEWARPOVFLAGS", SCREENDATASIDEWARPOVFLAGS, 0, 0 },
47355 {"SCREENDATAWARPARRIVALX", SCREENDATAWARPARRIVALX, 0, 0 },
47356 {"SCREENDATAWARPARRIVALY", SCREENDATAWARPARRIVALY, 0, 0 },
47357 {"SCREENDATAPATH", SCREENDATAPATH, 0, 0 },
47358 {"SCREENDATASIDEWARPSC", SCREENDATASIDEWARPSC, 0, 0 },
47359 {"SCREENDATASIDEWARPDMAP", SCREENDATASIDEWARPDMAP, 0, 0 },
47360 {"SCREENDATASIDEWARPINDEX", SCREENDATASIDEWARPINDEX, 0, 0 },
47361 {"SCREENDATAUNDERCOMBO", SCREENDATAUNDERCOMBO, 0, 0 },
47362 {"SCREENDATAUNDERCSET", SCREENDATAUNDERCSET, 0, 0 },
47363 {"SCREENDATACATCHALL", SCREENDATACATCHALL, 0, 0 },
47364 {"SCREENDATAFLAGS", SCREENDATAFLAGS, 0, 0 },
47365 {"SCREENDATACSENSITIVE", SCREENDATACSENSITIVE, 0, 0 },
47366 {"SCREENDATANORESET", SCREENDATANORESET, 0, 0 },
47367 {"SCREENDATANOCARRY", SCREENDATANOCARRY, 0, 0 },
47368 {"SCREENDATALAYERMAP", SCREENDATALAYERMAP, 0, 0 },
47369 {"SCREENDATALAYERSCREEN", SCREENDATALAYERSCREEN, 0, 0 },
47370 {"SCREENDATALAYEROPACITY", SCREENDATALAYEROPACITY, 0, 0 },
47371 {"SCREENDATATIMEDWARPTICS", SCREENDATATIMEDWARPTICS, 0, 0 },
47372 {"SCREENDATANEXTMAP", SCREENDATANEXTMAP, 0, 0 },
47373 {"SCREENDATANEXTSCREEN", SCREENDATANEXTSCREEN, 0, 0 },
47374 {"SCREENDATASECRETCOMBO", SCREENDATASECRETCOMBO, 0, 0 },
47375 {"SCREENDATASECRETCSET", SCREENDATASECRETCSET, 0, 0 },
47376 {"SCREENDATASECRETFLAG", SCREENDATASECRETFLAG, 0, 0 },
47377 {"SCREENDATAVIEWX", SCREENDATAVIEWX, 0, 0 },
47378 {"SCREENDATAVIEWY", SCREENDATAVIEWY, 0, 0 },
47379 {"SCREENDATASCREENWIDTH", SCREENDATASCREENWIDTH, 0, 0 },
47380 {"SCREENDATASCREENHEIGHT", SCREENDATASCREENHEIGHT, 0, 0 },
47381 {"SCREENDATAENTRYX", SCREENDATAENTRYX, 0, 0 },
47382 {"SCREENDATAENTRYY", SCREENDATAENTRYY, 0, 0 },
47383 {"SCREENDATANUMFF", SCREENDATANUMFF, 0, 0 },
47384 {"SCREENDATAFFDATA", SCREENDATAFFDATA, 0, 0 },
47385 {"SCREENDATAFFCSET", SCREENDATAFFCSET, 0, 0 },
47386 {"SCREENDATAFFDELAY", SCREENDATAFFDELAY, 0, 0 },
47387 {"SCREENDATAFFX", SCREENDATAFFX, 0, 0 },
47388 {"SCREENDATAFFY", SCREENDATAFFY, 0, 0 },
47389 {"SCREENDATAFFXDELTA", SCREENDATAFFXDELTA, 0, 0 },
47390 {"SCREENDATAFFYDELTA", SCREENDATAFFYDELTA, 0, 0 },
47391 {"SCREENDATAFFXDELTA2", SCREENDATAFFXDELTA2, 0, 0 },
47392 {"SCREENDATAFFYDELTA2", SCREENDATAFFYDELTA2, 0, 0 },
47393 {"SCREENDATAFFFLAGS", SCREENDATAFFFLAGS, 0, 0 },
47394 {"SCREENDATAFFWIDTH", SCREENDATAFFWIDTH, 0, 0 },
47395 {"SCREENDATAFFHEIGHT", SCREENDATAFFHEIGHT, 0, 0 },
47396 {"SCREENDATAFFLINK", SCREENDATAFFLINK, 0, 0 },
47397 {"SCREENDATAFFSCRIPT", SCREENDATAFFSCRIPT, 0, 0 },
47398 {"SCREENDATAINTID", SCREENDATAINTID, 0, 0 }, //Needs to be a function [32][10]
47399 {"SCREENDATAINITA", SCREENDATAINITA, 0, 0 }, //needs to be a function, [32][2]
47400 {"SCREENDATAFFINITIALISED", SCREENDATAFFINITIALISED, 0, 0 },
47401 {"SCREENDATASCRIPTENTRY", SCREENDATASCRIPTENTRY, 0, 0 },
47402 {"SCREENDATASCRIPTOCCUPANCY", SCREENDATASCRIPTOCCUPANCY, 0, 0 },
47403 {"SCREENDATASCRIPTEXIT", SCREENDATASCRIPTEXIT, 0, 0 },
47404 {"SCREENDATAOCEANSFX", SCREENDATAOCEANSFX, 0, 0 },
47405 {"SCREENDATABOSSSFX", SCREENDATABOSSSFX, 0, 0 },
47406 {"SCREENDATASECRETSFX", SCREENDATASECRETSFX, 0, 0 },
47407 {"SCREENDATAHOLDUPSFX", SCREENDATAHOLDUPSFX, 0, 0 },
47408 {"SCREENDATASCREENMIDI", SCREENDATASCREENMIDI, 0, 0 },
47409 {"SCREENDATALENSLAYER", SCREENDATALENSLAYER, 0, 0 },
47410
47411 {"LINKSCRIPTTILE", LINKSCRIPTTILE, 0, 0 },
47412 {"LINKSCRIPFLIP", LINKSCRIPFLIP, 0, 0 },
47413 {"MAPDATAITEMX", MAPDATAITEMX, 0, 0 },
47414 {"MAPDATAITEMY", MAPDATAITEMY, 0, 0 },
47415 {"SCREENDATAITEMX", SCREENDATAITEMX, 0, 0 },
47416 {"SCREENDATAITEMY", SCREENDATAITEMY, 0, 0 },
47417
47418 {"MAPDATAFFEFFECTWIDTH", MAPDATAFFEFFECTWIDTH, 0, 0 },
47419 {"MAPDATAFFEFFECTHEIGHT", MAPDATAFFEFFECTHEIGHT, 0, 0 },
47420 {"SCREENDATAFFEFFECTWIDTH", SCREENDATAFFEFFECTWIDTH, 0, 0 },
47421 {"SCREENDATAFFEFFECTHEIGHT", SCREENDATAFFEFFECTHEIGHT, 0, 0 },
47422
47423 {"LOADMAPDATA", LOADMAPDATA, 0, 0 },
47424 {"LWPNPARENT", LWPNPARENT, 0, 0 },
47425 {"LWPNLEVEL", LWPNLEVEL, 0, 0 },
47426 {"EWPNLEVEL", EWPNLEVEL, 0, 0 },
47427 {"EWPNPARENT", EWPNPARENT, 0, 0 },
47428
47429
47430 {"SHOPDATANAME", SHOPDATANAME, 0, 0 },
47431 {"SHOPDATAITEM", SHOPDATAITEM, 0, 0 },
47432 {"SHOPDATAHASITEM", SHOPDATAHASITEM, 0, 0 },
47433 {"SHOPDATAPRICE", SHOPDATAPRICE, 0, 0 },
47434 {"SHOPDATASTRING", SHOPDATASTRING, 0, 0 },
47435
47436 {"NPCDATASHIELD", NPCDATASHIELD, 0, 0 },
47437 {"NPCSHIELD", NPCSHIELD, 0, 0 },
47438 {"AUDIOVOLUME", AUDIOVOLUME, 0, 0 },
47439 {"AUDIOPAN", AUDIOPAN, 0, 0 },
47440
47441 {"MESSAGEDATANEXT", MESSAGEDATANEXT, 0, 0 },
47442 {"MESSAGEDATATILE", MESSAGEDATATILE, 0, 0 },
47443 {"MESSAGEDATACSET", MESSAGEDATACSET, 0, 0 },
47444 {"MESSAGEDATATRANS", MESSAGEDATATRANS, 0, 0 },
47445 {"MESSAGEDATAFONT", MESSAGEDATAFONT, 0, 0 },
47446 {"MESSAGEDATAX", MESSAGEDATAX, 0, 0 },
47447 {"MESSAGEDATAY", MESSAGEDATAY, 0, 0 },
47448 {"MESSAGEDATAW", MESSAGEDATAW, 0, 0 },
47449 {"MESSAGEDATAH", MESSAGEDATAH, 0, 0 },
47450 {"MESSAGEDATASFX", MESSAGEDATASFX, 0, 0 },
47451 {"MESSAGEDATALISTPOS", MESSAGEDATALISTPOS, 0, 0 },
47452 {"MESSAGEDATAVSPACE", MESSAGEDATAVSPACE, 0, 0 },
47453 {"MESSAGEDATAHSPACE", MESSAGEDATAHSPACE, 0, 0 },
47454 {"MESSAGEDATAFLAGS", MESSAGEDATAFLAGS, 0, 0 },
47455
47456 {"DMAPDATAMAP", DMAPDATAMAP, 0, 0 },
47457 {"DMAPDATALEVEL", DMAPDATALEVEL, 0, 0 },
47458 {"DMAPDATAOFFSET", DMAPDATAOFFSET, 0, 0 },
47459 {"DMAPDATACOMPASS", DMAPDATACOMPASS, 0, 0 },
47460 {"DMAPDATAPALETTE", DMAPDATAPALETTE, 0, 0 },
47461 {"DMAPDATAMIDI", DMAPDATAMIDI, 0, 0 },
47462 {"DMAPDATACONTINUE", DMAPDATACONTINUE, 0, 0 },
47463 {"DMAPDATATYPE", DMAPDATATYPE, 0, 0 },
47464 {"DMAPDATAGRID", DMAPDATAGRID, 0, 0 },
47465 {"DMAPDATAMINIMAPTILE", DMAPDATAMINIMAPTILE, 0, 0 },
47466 {"DMAPDATAMINIMAPCSET", DMAPDATAMINIMAPCSET, 0, 0 },
47467 {"DMAPDATALARGEMAPTILE", DMAPDATALARGEMAPTILE, 0, 0 },
47468 {"DMAPDATALARGEMAPCSET", DMAPDATALARGEMAPCSET, 0, 0 },
47469 {"DMAPDATAMUISCTRACK", DMAPDATAMUISCTRACK, 0, 0 },
47470 {"DMAPDATASUBSCRA", DMAPDATASUBSCRA, 0, 0 },
47471 {"DMAPDATASUBSCRP", DMAPDATASUBSCRP, 0, 0 },
47472 {"DMAPDATADISABLEDITEMS", DMAPDATADISABLEDITEMS, 0, 0 },
47473 {"DMAPDATAFLAGS", DMAPDATAFLAGS, 0, 0 },
47474
47475 {"NPCFROZEN", NPCFROZEN, 0, 0 },
47476 {"NPCFROZENTILE", NPCFROZENTILE, 0, 0 },
47477 {"NPCFROZENCSET", NPCFROZENCSET, 0, 0 },
47478
47479 {"ITEMPSTRING", ITEMPSTRING, 0, 0 },
47480 {"ITEMPSTRINGFLAGS", ITEMPSTRINGFLAGS, 0, 0 },
47481 {"ITEMOVERRIDEFLAGS", ITEMOVERRIDEFLAGS, 0, 0 },
47482 {"LINKPUSH", LINKPUSH, 0, 0 },
47483 {"LINKSTUN", LINKSTUN, 0, 0 },
47484 {"IDATACOSTCOUNTER", IDATACOSTCOUNTER, 0, 0 },
47485 {"TYPINGMODE", TYPINGMODE, 0, 0 },
47486 // {"DMAPDATAGRAVITY", DMAPDATAGRAVITY, 0, 0 },
47487 // {"DMAPDATAJUMPLAYER", DMAPDATAJUMPLAYER, 0, 0 },
47488 //end ffscript vars
47489 //END VARS END OF BYTECODE
47490
47491 //newcombo
47492 {"COMBODTILE", COMBODTILE, 0, 0 },
47493 {"COMBODFLIP", COMBODFLIP, 0, 0 },
47494 {"COMBODWALK", COMBODWALK, 0, 0 },
47495 {"COMBODTYPE", COMBODTYPE, 0, 0 },
47496 {"COMBODCSET", COMBODCSET, 0, 0 },
47497 {"COMBODFOO", COMBODFOO, 0, 0 },
47498 {"COMBODFRAMES", COMBODFRAMES, 0, 0 },
47499 {"COMBODNEXTD", COMBODNEXTD, 0, 0 },
47500 {"COMBODNEXTC", COMBODNEXTC, 0, 0 },
47501 {"COMBODFLAG", COMBODFLAG, 0, 0 },
47502 {"COMBODSKIPANIM", COMBODSKIPANIM, 0, 0 },
47503 {"COMBODNEXTTIMER", COMBODNEXTTIMER, 0, 0 },
47504 {"COMBODAKIMANIMY", COMBODAKIMANIMY, 0, 0 },
47505 {"COMBODANIMFLAGS", COMBODANIMFLAGS, 0, 0 },
47506 {"COMBODEXPANSION", COMBODEXPANSION, 0, 0 },
47507 {"COMBODATTRIBUTES", COMBODATTRIBUTES, 0, 0 },
47508 {"COMBODATTRIBYTES", COMBODATTRIBYTES, 0, 0 },
47509 {"COMBODUSRFLAGS", COMBODUSRFLAGS, 0, 0 },
47510 {"COMBODTRIGGERFLAGS", COMBODTRIGGERFLAGS, 0, 0 },
47511 {"COMBODTRIGGERLEVEL", COMBODTRIGGERLEVEL, 0, 0 },
47512
47513 //comboclass
47514 {"COMBODNAME", COMBODNAME, 0, 0 },
47515 {"COMBODBLOCKNPC", COMBODBLOCKNPC, 0, 0 },
47516 {"COMBODBLOCKHOLE", COMBODBLOCKHOLE, 0, 0 },
47517 {"COMBODBLOCKTRIG", COMBODBLOCKTRIG, 0, 0 },
47518 {"COMBODBLOCKWEAPON", COMBODBLOCKWEAPON, 0, 0 },
47519 {"COMBODCONVXSPEED", COMBODCONVXSPEED, 0, 0 },
47520 {"COMBODCONVYSPEED", COMBODCONVYSPEED, 0, 0 },
47521 {"COMBODSPAWNNPC", COMBODSPAWNNPC, 0, 0 },
47522 {"COMBODSPAWNNPCWHEN", COMBODSPAWNNPCWHEN, 0, 0 },
47523 {"COMBODSPAWNNPCCHANGE", COMBODSPAWNNPCCHANGE, 0, 0 },
47524 {"COMBODDIRCHANGETYPE", COMBODDIRCHANGETYPE, 0, 0 },
47525 {"COMBODDISTANCECHANGETILES", COMBODDISTANCECHANGETILES, 0, 0 },
47526 {"COMBODDIVEITEM", COMBODDIVEITEM, 0, 0 },
47527 {"COMBODDOCK", COMBODDOCK, 0, 0 },
47528 {"COMBODFAIRY", COMBODFAIRY, 0, 0 },
47529 {"COMBODFFATTRCHANGE", COMBODFFATTRCHANGE, 0, 0 },
47530 {"COMBODFOORDECOTILE", COMBODFOORDECOTILE, 0, 0 },
47531 {"COMBODFOORDECOTYPE", COMBODFOORDECOTYPE, 0, 0 },
47532 {"COMBODHOOKSHOTPOINT", COMBODHOOKSHOTPOINT, 0, 0 },
47533 {"COMBODLADDERPASS", COMBODLADDERPASS, 0, 0 },
47534 {"COMBODLOCKBLOCK", COMBODLOCKBLOCK, 0, 0 },
47535 {"COMBODLOCKBLOCKCHANGE", COMBODLOCKBLOCKCHANGE, 0, 0 },
47536 {"COMBODMAGICMIRROR", COMBODMAGICMIRROR, 0, 0 },
47537 {"COMBODMODHPAMOUNT", COMBODMODHPAMOUNT, 0, 0 },
47538 {"COMBODMODHPDELAY", COMBODMODHPDELAY, 0, 0 },
47539 {"COMBODMODHPTYPE", COMBODMODHPTYPE, 0, 0 },
47540 {"COMBODNMODMPAMOUNT", COMBODNMODMPAMOUNT, 0, 0 },
47541 {"COMBODMODMPDELAY", COMBODMODMPDELAY, 0, 0 },
47542 {"COMBODMODMPTYPE", COMBODMODMPTYPE, 0, 0 },
47543 {"COMBODNOPUSHBLOCK", COMBODNOPUSHBLOCK, 0, 0 },
47544 {"COMBODOVERHEAD", COMBODOVERHEAD, 0, 0 },
47545 {"COMBODPLACENPC", COMBODPLACENPC, 0, 0 },
47546 {"COMBODPUSHDIR", COMBODPUSHDIR, 0, 0 },
47547 {"COMBODPUSHWAIT", COMBODPUSHWAIT, 0, 0 },
47548 {"COMBODPUSHHEAVY", COMBODPUSHHEAVY, 0, 0 },
47549 {"COMBODPUSHED", COMBODPUSHED, 0, 0 },
47550 {"COMBODRAFT", COMBODRAFT, 0, 0 },
47551 {"COMBODRESETROOM", COMBODRESETROOM, 0, 0 },
47552 {"COMBODSAVEPOINTTYPE", COMBODSAVEPOINTTYPE, 0, 0 },
47553 {"COMBODSCREENFREEZETYPE", COMBODSCREENFREEZETYPE, 0, 0 },
47554 {"COMBODSECRETCOMBO", COMBODSECRETCOMBO, 0, 0 },
47555 {"COMBODSINGULAR", COMBODSINGULAR, 0, 0 },
47556 {"COMBODSLOWWALK", COMBODSLOWWALK, 0, 0 },
47557 {"COMBODSTATUETYPEs", COMBODSTATUETYPE, 0, 0 },
47558 {"COMBODSTEPTYPE", COMBODSTEPTYPE, 0, 0 },
47559 {"COMBODSTEPCHANGEINTO", COMBODSTEPCHANGEINTO, 0, 0 },
47560 {"COMBODSTRIKEWEAPONS", COMBODSTRIKEWEAPONS, 0, 0 },
47561 {"COMBODSTRIKEREMNANTS", COMBODSTRIKEREMNANTS, 0, 0 },
47562 {"COMBODSTRIKEREMNANTSTYPE", COMBODSTRIKEREMNANTSTYPE, 0, 0 },
47563 {"COMBODSTRIKECHANGE", COMBODSTRIKECHANGE, 0, 0 },
47564 {"COMBODSTRIKEITEM", COMBODSTRIKEITEM, 0, 0 },
47565 {"COMBODTOUCHITEM", COMBODTOUCHITEM, 0, 0 },
47566 {"COMBODTOUCHSTAIRS", COMBODTOUCHSTAIRS, 0, 0 },
47567 {"COMBODTRIGGERTYPE", COMBODTRIGGERTYPE, 0, 0 },
47568 {"COMBODTRIGGERSENS", COMBODTRIGGERSENS, 0, 0 },
47569 {"COMBODWARPTYPE", COMBODWARPTYPE, 0, 0 },
47570 {"COMBODWARPSENS", COMBODWARPSENS, 0, 0 },
47571 {"COMBODWARPDIRECT", COMBODWARPDIRECT, 0, 0 },
47572 {"COMBODWARPLOCATION", COMBODWARPLOCATION, 0, 0 },
47573 {"COMBODWATER", COMBODWATER, 0, 0 },
47574 {"COMBODWHISTLE", COMBODWHISTLE, 0, 0 },
47575 {"COMBODWINGAME", COMBODWINGAME, 0, 0 },
47576 {"COMBODBLOCKWPNLEVEL", COMBODBLOCKWPNLEVEL, 0, 0 },
47577
47578 {"TYPINGMODE", TYPINGMODE, 0, 0 },
47579 {"TYPINGMODE", TYPINGMODE, 0, 0 },
47580 {"LINKHITBY", LINKHITBY, 0, 0 },
47581 {"LINKDEFENCE", LINKDEFENCE, 0, 0 },
47582 {"NPCHITBY", NPCHITBY, 0, 0 },
47583 {"NPCISCORE", NPCISCORE, 0, 0 },
47584 {"NPCSCRIPTUID", NPCSCRIPTUID, 0, 0 },
47585 {"LWEAPONSCRIPTUID", LWEAPONSCRIPTUID, 0, 0 },
47586 {"EWEAPONSCRIPTUID", EWEAPONSCRIPTUID, 0, 0 },
47587 {"ITEMSCRIPTUID", ITEMSCRIPTUID, 0, 0 },
47588
47589 {"DMAPDATASIDEVIEW", DMAPDATASIDEVIEW, 0, 0 },
47590
47591 {"DONULL", DONULL, 0, 0 },
47592 {"DEBUGD", DEBUGD, 0, 0 },
47593 {"GETPIXEL", GETPIXEL, 0, 0 },
47594 {"DOUNTYPE", DOUNTYPE, 0, 0 },
47595 {"NPCBEHAVIOUR", NPCBEHAVIOUR, 0, 0 },
47596 {"NPCDATABEHAVIOUR", NPCDATABEHAVIOUR, 0, 0 },
47597 {"CREATEBITMAP", CREATEBITMAP, 0, 0 },
47598 {"LINKTILEMOD", LINKTILEMOD, 0, 0 },
47599 {"NPCINITD", NPCINITD, 0, 0 },
47600 {"NPCCOLLISION", NPCCOLLISION, 0, 0 },
47601 {"NPCLINEDUP", NPCLINEDUP, 0, 0 },
47602
47603 {"NPCDATAINITD", NPCLINEDUP, 0, 0 },
47604 {"NPCDATASCRIPT", NPCDATASCRIPT, 0, 0 },
47605 {"NPCMATCHINITDLABEL", NPCMATCHINITDLABEL, 0, 0 },
47606 //lweapon scripts
47607 {"LWPNSCRIPT", LWPNSCRIPT, 0, 0 },
47608 {"LWPNINITD", LWPNINITD, 0, 0 },
47609 {"ITEMFAMILY", ITEMFAMILY, 0, 0 },
47610 {"ITEMLEVEL", ITEMLEVEL, 0, 0 },
47611
47612 {"EWPNSCRIPT", EWPNSCRIPT, 0, 0 },
47613 {"EWPNINITD", EWPNINITD, 0, 0 },
47614
47615 {"NPCSCRIPT", NPCSCRIPT, 0, 0 },
47616
47617 {"DMAPSCRIPT", DMAPSCRIPT, 0, 0 },
47618 {"DMAPINITD", DMAPINITD, 0, 0 },
47619
47620 {"SCREENSCRIPT", SCREENSCRIPT, 0, 0 },
47621 {"SCREENINITD", SCREENINITD, 0, 0 },
47622
47623 {"LINKINITD", LINKINITD, 0, 0 },
47624 {"NPCDATAWEAPONINITD", NPCDATAWEAPONINITD, 0, 0 },
47625 {"NPCDATAWEAPONSCRIPT", NPCDATAWEAPONSCRIPT, 0, 0 },
47626
47627 {"NPCSCRIPTTILE", NPCSCRIPTTILE, 0, 0 },
47628 {"NPCSCRIPTFLIP", NPCSCRIPTFLIP, 0, 0 },
47629 {"LWPNSCRIPTTILE", LWPNSCRIPTTILE, 0, 0 },
47630 {"LWPNSCRIPTFLIP", LWPNSCRIPTFLIP, 0, 0 },
47631 {"EWPNSCRIPTTILE", EWPNSCRIPTTILE, 0, 0 },
47632 {"EWPNSCRIPTFLIP", EWPNSCRIPTFLIP, 0, 0 },
47633
47634 {"LINKENGINEANIMATE", LINKENGINEANIMATE, 0, 0 },
47635 {"NPCENGINEANIMATE", NPCENGINEANIMATE, 0, 0 },
47636 {"LWPNENGINEANIMATE", LWPNENGINEANIMATE, 0, 0 },
47637 {"EWPNENGINEANIMATE", EWPNENGINEANIMATE, 0, 0 },
47638 {"SKIPCREDITS", SKIPCREDITS, 0, 0 },
47639 {"SKIPF6", SKIPF6, 0, 0 },
47640 {"LWPNUSEWEAPON", LWPNUSEWEAPON, 0, 0 },
47641 {"LWPNUSEDEFENCE", LWPNUSEDEFENCE, 0, 0 },
47642 {"LWPNROTATION", LWPNROTATION, 0, 0 },
47643 {"EWPNROTATION", EWPNROTATION, 0, 0 },
47644 {"NPCROTATION", NPCROTATION, 0, 0 },
47645 {"ITEMROTATION", ITEMROTATION, 0, 0 },
47646 {"LINKROTATION", LINKROTATION, 0, 0 },
47647 {"LWPNSCALE", LWPNSCALE, 0, 0 },
47648 {"EWPNSCALE", EWPNSCALE, 0, 0 },
47649 {"NPCSCALE", NPCSCALE, 0, 0 },
47650 {"ITEMSCALE", ITEMSCALE, 0, 0 },
47651 {"LINKSCALE", LINKSCALE, 0, 0 },
47652 {"ITEMSPRITESCRIPT", ITEMSPRITESCRIPT, 0, 0 },
47653 {"FFRULE", FFRULE, 0, 0 },
47654 {"NUMDRAWS", NUMDRAWS, 0, 0 },
47655 {"MAXDRAWS", MAXDRAWS, 0, 0 },
47656 {"BITMAPWIDTH", BITMAPWIDTH, 0, 0 },
47657 {"BITMAPHEIGHT", BITMAPHEIGHT, 0, 0 },
47658 {"ALLOCATEBITMAPR", ALLOCATEBITMAPR, 0, 0 },
47659 {"KEYMODIFIERS", KEYMODIFIERS, 0, 0 },
47660 {"SIMULATEKEYPRESS", SIMULATEKEYPRESS, 0, 0 },
47661 {"KEYBINDINGS", KEYBINDINGS, 0, 0 },
47662
47663 {"SCREENSCRIPT", SCREENSCRIPT, 0, 0 },
47664 {"SCREENINITD", SCREENINITD, 0, 0 },
47665 {"MAPDATASCRIPT", MAPDATASCRIPT, 0, 0 },
47666 {"MAPDATAINITDARRAY", MAPDATAINITDARRAY, 0, 0 },
47667 {"LWPNGRAVITY", LWPNGRAVITY, 0, 0 },
47668 {"EWPNGRAVITY", EWPNGRAVITY, 0, 0 },
47669 {"NPCGRAVITY", NPCGRAVITY, 0, 0 },
47670 {"ITEMGRAVITY", ITEMGRAVITY, 0, 0 },
47671
47672 {"MAPDATASIDEWARPID", MAPDATASIDEWARPID, 0, 0 },
47673 {"SCREENSIDEWARPID", SCREENSIDEWARPID, 0, 0 },
47674 {"SCREENDATALAYERINVIS", SCREENDATALAYERINVIS, 0, 0 },
47675 {"SCREENDATASCRIPTDRAWS", SCREENDATASCRIPTDRAWS, 0, 0 },
47676 {"MAPDATALAYERINVIS", MAPDATALAYERINVIS, 0, 0 },
47677 {"MAPDATASCRIPTDRAWS", MAPDATASCRIPTDRAWS, 0, 0 },
47678
47679 {"ITEMSCRIPTTILE", ITEMSCRIPTTILE, 0, 0 },
47680 {"ITEMSCRIPTFLIP", ITEMSCRIPTFLIP, 0, 0 },
47681 {"MAPDATAMAP", MAPDATAMAP, 0, 0 },
47682 {"MAPDATASCREEN", MAPDATASCREEN, 0, 0 },
47683 {"IDATAVALIDATE", IDATAVALIDATE, 0, 0 },
47684 { "DISABLEKEY", DISABLEKEY, 0, 0 },
47685 { "DISABLEBUTTON", DISABLEBUTTON, 0, 0 },
47686 { "GAMESUSPEND", GAMESUSPEND, 0, 0 },
47687 { "LINKOTILE", LINKOTILE, 0, 0 },
47688 { "LINKOFLIP", LINKOFLIP, 0, 0 },
47689 { "ITEMSPRITEINITD", ITEMSPRITEINITD, 0, 0 },
47690
47691 { "ZSCRIPTVERSION", ZSCRIPTVERSION, 0, 0 },
47692 { "REFFILE", REFFILE, 0, 0 },
47693 { "LINKCLIMBING", LINKCLIMBING, 0, 0 },
47694 { "NPCIMMORTAL", NPCIMMORTAL, 0, 0 },
47695 { "NPCNOSLIDE", NPCNOSLIDE, 0, 0 },
47696 { "NPCKNOCKBACKSPEED", NPCKNOCKBACKSPEED, 0, 0 },
47697 { "NPCNOSCRIPTKB", NPCNOSCRIPTKB, 0, 0 },
47698 { "GETRENDERTARGET", GETRENDERTARGET, 0, 0 },
47699 { "HERONOSTEPFORWARD", HERONOSTEPFORWARD, 0, 0 },
47700 { "SCREENDATATWARPRETSQR", SCREENDATATWARPRETSQR, 0, 0 },
47701 { "SCREENDATASWARPRETSQR", SCREENDATASWARPRETSQR, 0, 0 },
47702 { "MAPDATATWARPRETSQR", MAPDATATWARPRETSQR, 0, 0 },
47703 { "MAPDATASWARPRETSQR", MAPDATASWARPRETSQR, 0, 0 },
47704 { "NPCSUBMERGED", NPCSUBMERGED, 0, 0 },
47705 { "GAMEGRAVITY", GAMEGRAVITY, 0, 0 },
47706 { "COMBODASPEED", COMBODASPEED, 0, 0 },
47707 { "DROPSETITEMS", DROPSETITEMS, 0, 0 },
47708 { "DROPSETCHANCES", DROPSETCHANCES, 0, 0 },
47709 { "DROPSETNULLCHANCE", DROPSETNULLCHANCE, 0, 0 },
47710 { "DROPSETCHOOSE", DROPSETCHOOSE, 0, 0 },
47711 { "NPCPARENTUID", NPCPARENTUID, 0, 0 },
47712 { "KEYPRESS", KEYPRESS, 0, 0 },
47713 { "KEYINPUT", KEYINPUT, 0, 0 },
47714 { "SPRITEMAXNPC", SPRITEMAXNPC, 0, 0 },
47715 { "SPRITEMAXLWPN", SPRITEMAXLWPN, 0, 0 },
47716 { "SPRITEMAXEWPN", SPRITEMAXEWPN, 0, 0 },
47717 { "SPRITEMAXITEM", SPRITEMAXITEM, 0, 0 },
47718 { "SPRITEMAXPARTICLE", SPRITEMAXPARTICLE, 0, 0 },
47719 { "SPRITEMAXDECO", SPRITEMAXDECO, 0, 0 },
47720 { "HEROHEALTHBEEP", HEROHEALTHBEEP, 0, 0 },
47721 { "NPCRANDOM", NPCRANDOM, 0, 0 },
47722 { "COMBOXR", COMBOXR, 0, 0 },
47723 { "COMBOYR", COMBOYR, 0, 0 },
47724 { "COMBOPOSR", COMBOPOSR, 0, 0 },
47725 { "COMBODATASCRIPT", COMBODATASCRIPT, 0, 0 },
47726 { "COMBODATAINITD", COMBODATAINITD, 0, 0 },
47727 { "HEROSCRIPTCSET", HEROSCRIPTCSET, 0, 0 },
47728 { "SHOPDATATYPE", SHOPDATATYPE, 0, 0 },
47729 { "HEROSTEPS", HEROSTEPS, 0, 0 },
47730 { "HEROSTEPRATE", HEROSTEPRATE, 0, 0 },
47731 { "COMBODOTILE", COMBODOTILE, 0, 0 },
47732 { "COMBODFRAME", COMBODFRAME, 0, 0 },
47733 { "COMBODACLK", COMBODACLK, 0, 0 },
47734 { "PC", PC, 0, 0 },
47735 { "GAMESCROLLING", GAMESCROLLING, 0, 0 },
47736 { "MESSAGEDATAMARGINS", MESSAGEDATAMARGINS, 0, 0 },
47737 { "MESSAGEDATAPORTTILE", MESSAGEDATAPORTTILE, 0, 0 },
47738 { "MESSAGEDATAPORTCSET", MESSAGEDATAPORTCSET, 0, 0 },
47739 { "MESSAGEDATAPORTX", MESSAGEDATAPORTX, 0, 0 },
47740 { "MESSAGEDATAPORTY", MESSAGEDATAPORTY, 0, 0 },
47741 { "MESSAGEDATAPORTWID", MESSAGEDATAPORTWID, 0, 0 },
47742 { "MESSAGEDATAPORTHEI", MESSAGEDATAPORTHEI, 0, 0 },
47743 { "MESSAGEDATAFLAGSARR", MESSAGEDATAFLAGSARR, 0, 0 },
47744 { "FILEPOS", FILEPOS, 0, 0 },
47745 { "FILEEOF", FILEEOF, 0, 0 },
47746 { "FILEERR", FILEERR, 0, 0 },
47747 { "MESSAGEDATATEXTWID", MESSAGEDATATEXTWID, 0, 0 },
47748 { "MESSAGEDATATEXTHEI", MESSAGEDATATEXTHEI, 0, 0 },
47749 { "SWITCHKEY", SWITCHKEY, 0, 0 },
47750 { "INCQST", INCQST, 0, 0 },
47751 { "HEROJUMPCOUNT", HEROJUMPCOUNT, 0, 0 },
47752 { "HEROPULLDIR", HEROPULLDIR, 0, 0 },
47753 { "HEROPULLCLK", HEROPULLCLK, 0, 0 },
47754 { "HEROFALLCLK", HEROFALLCLK, 0, 0 },
47755 { "HEROFALLCMB", HEROFALLCMB, 0, 0 },
47756 { "HEROMOVEFLAGS", HEROMOVEFLAGS, 0, 0 },
47757 { "ITEMFALLCLK", ITEMFALLCLK, 0, 0 },
47758 { "ITEMFALLCMB", ITEMFALLCMB, 0, 0 },
47759 { "ITEMMOVEFLAGS", ITEMMOVEFLAGS, 0, 0 },
47760 { "LWPNFALLCLK", LWPNFALLCLK, 0, 0 },
47761 { "LWPNFALLCMB", LWPNFALLCMB, 0, 0 },
47762 { "LWPNMOVEFLAGS", LWPNMOVEFLAGS, 0, 0 },
47763 { "EWPNFALLCLK", EWPNFALLCLK, 0, 0 },
47764 { "EWPNFALLCMB", EWPNFALLCMB, 0, 0 },
47765 { "EWPNMOVEFLAGS", EWPNMOVEFLAGS, 0, 0 },
47766 { "NPCFALLCLK", NPCFALLCLK, 0, 0 },
47767 { "NPCFALLCMB", NPCFALLCMB, 0, 0 },
47768 { "NPCMOVEFLAGS", NPCMOVEFLAGS, 0, 0 },
47769 { "ISBLANKTILE", ISBLANKTILE, 0, 0 },
47770 { "LWPNSPECIAL", LWPNSPECIAL, 0, 0 },
47771 { "DMAPDATAASUBSCRIPT", DMAPDATAASUBSCRIPT, 0, 0 },
47772 { "DMAPDATAPSUBSCRIPT", DMAPDATAPSUBSCRIPT, 0, 0 },
47773 { "DMAPDATASUBINITD", DMAPDATASUBINITD, 0, 0 },
47774 { "MODULEGETINT", MODULEGETINT, 0, 0 },
47775 { "MODULEGETSTR", MODULEGETSTR, 0, 0 },
47776 { "NPCORIGINALHP", NPCORIGINALHP, 0, 0 },
47777 { "DMAPDATAMAPSCRIPT", DMAPDATAMAPSCRIPT, 0, 0 },
47778 { "DMAPDATAMAPINITD", DMAPDATAMAPINITD, 0, 0 },
47779 { "CLOCKCLK", CLOCKCLK, 0, 0 },
47780 { "CLOCKACTIVE", CLOCKACTIVE, 0, 0 },
47781 { "NPCHITDIR", NPCHITDIR, 0, 0 },
47782 { "DMAPDATAFLAGARR", DMAPDATAFLAGARR, 0, 0 },
47783 { "LINKCSET", LINKCSET, 0, 0 },
47784 { "NPCSLIDECLK", NPCSLIDECLK, 0, 0 },
47785 { "NPCFADING", NPCFADING, 0, 0 },
47786 { "DISTANCE", DISTANCE, 0, 0 },
47787 { "STDARR", STDARR, 0, 0 },
47788 { "GHOSTARR", GHOSTARR, 0, 0 },
47789 { "TANGOARR", TANGOARR, 0, 0 },
47790 { "NPCHALTCLK", NPCHALTCLK, 0, 0 },
47791 { "NPCMOVESTATUS", NPCMOVESTATUS, 0, 0 },
47792 { "DISTANCESCALE", DISTANCESCALE, 0, 0 },
47793 { "DMAPDATACHARTED", DMAPDATACHARTED, 0, 0 },
47794 { "REFDIRECTORY", REFDIRECTORY, 0, 0 },
47795 { "DIRECTORYSIZE", DIRECTORYSIZE, 0, 0 },
47796 { "LONGDISTANCE", LONGDISTANCE, 0, 0 },
47797 { "LONGDISTANCESCALE", LONGDISTANCESCALE, 0, 0 },
47798 { "COMBOED", COMBOED, 0, 0 },
47799 { "MAPDATACOMBOED", MAPDATACOMBOED, 0, 0 },
47800 { "COMBODEFFECT", COMBODEFFECT, 0, 0 },
47801 { "SCREENSECRETSTRIGGERED", SCREENSECRETSTRIGGERED, 0, 0 },
47802 { "ITEMDIR", ITEMDIR, 0, 0 },
47803 { "NPCFRAME", NPCFRAME, 0, 0 },
47804 { "LINKITEMX", LINKITEMX, 0, 0 },
47805 { "LINKITEMY", LINKITEMY, 0, 0 },
47806 { "ACTIVESSSPEED", ACTIVESSSPEED, 0, 0 },
47807 { "HEROISWARPING", HEROISWARPING, 0, 0 },
47808 { "ITEMGLOWRAD", ITEMGLOWRAD, 0, 0 },
47809 { "NPCGLOWRAD", NPCGLOWRAD, 0, 0 },
47810 { "LWPNGLOWRAD", LWPNGLOWRAD, 0, 0 },
47811 { "EWPNGLOWRAD", EWPNGLOWRAD, 0, 0 },
47812 { "ITEMGLOWSHP", ITEMGLOWSHP, 0, 0 },
47813 { "NPCGLOWSHP", NPCGLOWSHP, 0, 0 },
47814 { "LWPNGLOWSHP", LWPNGLOWSHP, 0, 0 },
47815 { "EWPNGLOWSHP", EWPNGLOWSHP, 0, 0 },
47816 { "ITEMENGINEANIMATE", ITEMENGINEANIMATE, 0, 0 },
47817 { "REFRNG", REFRNG, 0, 0 },
47818 { "LWPNUNBL", LWPNUNBL, 0, 0 },
47819 { "EWPNUNBL", EWPNUNBL, 0, 0 },
47820 { "NPCSHADOWSPR", NPCSHADOWSPR, 0, 0 },
47821 { "LWPNSHADOWSPR", LWPNSHADOWSPR, 0, 0 },
47822 { "EWPNSHADOWSPR", EWPNSHADOWSPR, 0, 0 },
47823 { "ITEMSHADOWSPR", ITEMSHADOWSPR, 0, 0 },
47824 { "NPCSPAWNSPR", NPCSPAWNSPR, 0, 0 },
47825 { "NPCDEATHSPR", NPCDEATHSPR, 0, 0 },
47826 { "NPCDSHADOWSPR", NPCDSHADOWSPR, 0, 0 },
47827 { "NPCDSPAWNSPR", NPCDSPAWNSPR, 0, 0 },
47828 { "NPCDDEATHSPR", NPCDDEATHSPR, 0, 0 },
47829
47830 { "COMBOLAYERR", COMBOLAYERR, 0, 0 },
47831 { "COMBODATTRISHORTS", COMBODATTRISHORTS, 0, 0 },
47832
47833 { "PUSHBLOCKLAYER", PUSHBLOCKLAYER, 0, 0 },
47834 { "LINKGRABBED", LINKGRABBED, 0, 0 },
47835 { "HEROBUNNY", HEROBUNNY, 0, 0 },
47836
47837 { "GAMELSWITCH", GAMELSWITCH, 0, 0 },
47838 { "GAMEBOTTLEST", GAMEBOTTLEST, 0, 0 },
47839
47840 { "REFBOTTLETYPE", REFBOTTLETYPE, 0, 0 },
47841 { "REFBOTTLESHOP", REFBOTTLESHOP, 0, 0 },
47842 { "BOTTLECOUNTER", BOTTLECOUNTER, 0, 0 },
47843 { "BOTTLEAMOUNT", BOTTLEAMOUNT, 0, 0 },
47844 { "BOTTLEPERCENT", BOTTLEPERCENT, 0, 0 },
47845 { "BOTTLEFLAGS", BOTTLEFLAGS, 0, 0 },
47846 { "BOTTLENEXT", BOTTLENEXT, 0, 0 },
47847 { "BSHOPFILL", BSHOPFILL, 0, 0 },
47848 { "BSHOPCOMBO", BSHOPCOMBO, 0, 0 },
47849 { "BSHOPCSET", BSHOPCSET, 0, 0 },
47850 { "BSHOPPRICE", BSHOPPRICE, 0, 0 },
47851 { "BSHOPSTR", BSHOPSTR, 0, 0 },
47852 { "COMBODUSRFLAGARR", COMBODUSRFLAGARR, 0, 0 },
47853 { "COMBODGENFLAGARR", COMBODGENFLAGARR, 0, 0 },
47854 { "HERORESPAWNX", HERORESPAWNX, 0, 0 },
47855 { "HERORESPAWNY", HERORESPAWNY, 0, 0 },
47856 { "HERORESPAWNDMAP", HERORESPAWNDMAP, 0, 0 },
47857 { "HERORESPAWNSCR", HERORESPAWNSCR, 0, 0 },
47858 { "IDATAUSESOUND2", IDATAUSESOUND2, 0, 0 },
47859 { "HEROSWITCHTIMER", HEROSWITCHTIMER, 0, 0 },
47860 { "HEROSWITCHMAXTIMER", HEROSWITCHMAXTIMER, 0, 0 },
47861 { "NPCSWHOOKED", NPCSWHOOKED, 0, 0 },
47862 { "GAMEMISCSPR", GAMEMISCSPR, 0, 0 },
47863 { "GAMEMISCSFX", GAMEMISCSFX, 0, 0 },
47864 { "HEROTOTALDYOFFS", HEROTOTALDYOFFS, 0, 0 },
47865 { "NPCTOTALDYOFFS", NPCTOTALDYOFFS, 0, 0 },
47866 { "LWPNTOTALDYOFFS", LWPNTOTALDYOFFS, 0, 0 },
47867 { "EWPNTOTALDYOFFS", EWPNTOTALDYOFFS, 0, 0 },
47868 { "LWSWHOOKED", LWSWHOOKED, 0, 0 },
47869 { "EWSWHOOKED", EWSWHOOKED, 0, 0 },
47870 { "ITMSWHOOKED", ITMSWHOOKED, 0, 0 },
47871 { "DEBUGTESTING", DEBUGTESTING, 0, 0 },
47872 { "GAMEMAXCHEAT", GAMEMAXCHEAT, 0, 0 },
47873 { "SHOWNMSG", SHOWNMSG, 0, 0 },
47874 { "COMBODTRIGGERBUTTON", COMBODTRIGGERBUTTON, 0, 0 },
47875 { "REFGENERICDATA", REFGENERICDATA, 0, 0 },
47876 { "GENDATARUNNING", GENDATARUNNING, 0, 0 },
47877 { "GENDATASIZE", GENDATASIZE, 0, 0 },
47878 { "GENDATAEXITSTATE", GENDATAEXITSTATE, 0, 0 },
47879 { "GENDATADATA", GENDATADATA, 0, 0 },
47880 { "GENDATAINITD", GENDATAINITD, 0, 0 },
47881 { "GENDATARELOADSTATE", GENDATARELOADSTATE, 0, 0 },
47882 { "COMBODCSET2FLAGS", COMBODCSET2FLAGS, 0, 0 },
47883 { "HEROIMMORTAL", HEROIMMORTAL, 0, 0 },
47884 { "NPCCANFLICKER", NPCCANFLICKER, 0, 0 },
47885 { "NPCDROWNCLK", NPCDROWNCLK, 0, 0 },
47886 { "NPCDROWNCMB", NPCDROWNCMB, 0, 0 },
47887 { "ITEMDROWNCLK", ITEMDROWNCLK, 0, 0 },
47888 { "ITEMDROWNCMB", ITEMDROWNCMB, 0, 0 },
47889 { "LWPNDROWNCLK", LWPNDROWNCLK, 0, 0 },
47890 { "LWPNDROWNCMB", LWPNDROWNCMB, 0, 0 },
47891 { "EWPNDROWNCLK", EWPNDROWNCLK, 0, 0 },
47892 { "EWPNDROWNCMB", EWPNDROWNCMB, 0, 0 },
47893 { "HERODROWNCLK", HERODROWNCLK, 0, 0 },
47894 { "HERODROWNCMB", HERODROWNCMB, 0, 0 },
47895 { "NPCFAKEZ", NPCFAKEZ, 0, 0 },
47896 { "ITEMFAKEZ", ITEMFAKEZ, 0, 0 },
47897 { "LWPNFAKEZ", LWPNFAKEZ, 0, 0 },
47898 { "EWPNFAKEZ", EWPNFAKEZ, 0, 0 },
47899 { "HEROFAKEZ", HEROFAKEZ, 0, 0 },
47900 { "NPCFAKEJUMP", NPCFAKEJUMP, 0, 0 },
47901 { "ITEMFAKEJUMP", ITEMFAKEJUMP, 0, 0 },
47902 { "LWPNFAKEJUMP", LWPNFAKEJUMP, 0, 0 },
47903 { "EWPNFAKEJUMP", EWPNFAKEJUMP, 0, 0 },
47904 { "HEROFAKEJUMP", HEROFAKEJUMP, 0, 0 },
47905 { "HEROSHADOWXOFS", HEROSHADOWXOFS, 0, 0 },
47906 { "HEROSHADOWYOFS", HEROSHADOWYOFS, 0, 0 },
47907 { "NPCSHADOWXOFS", NPCSHADOWXOFS, 0, 0 },
47908 { "NPCSHADOWYOFS", NPCSHADOWYOFS, 0, 0 },
47909 { "ITEMSHADOWXOFS", ITEMSHADOWXOFS, 0, 0 },
47910 { "ITEMSHADOWYOFS", ITEMSHADOWYOFS, 0, 0 },
47911 { "LWPNSHADOWXOFS", LWPNSHADOWXOFS, 0, 0 },
47912 { "LWPNSHADOWYOFS", LWPNSHADOWYOFS, 0, 0 },
47913 { "EWPNSHADOWXOFS", EWPNSHADOWXOFS, 0, 0 },
47914 { "EWPNSHADOWYOFS", EWPNSHADOWYOFS, 0, 0 },
47915 { "LWPNDEGANGLE", LWPNDEGANGLE, 0, 0 },
47916 { "EWPNDEGANGLE", EWPNDEGANGLE, 0, 0 },
47917 { "LWPNVX", LWPNVX, 0, 0 },
47918 { "LWPNVY", LWPNVY, 0, 0 },
47919 { "EWPNVX", EWPNVX, 0, 0 },
47920 { "EWPNVY", EWPNVY, 0, 0 },
47921 { "LWPNAUTOROTATE", LWPNAUTOROTATE, 0, 0 },
47922 { "EWPNAUTOROTATE", EWPNAUTOROTATE, 0, 0 },
47923 { "IDATACOSTCOUNTER2", IDATACOSTCOUNTER2, 0, 0 },
47924 { "IDATAMAGICTIMER2", IDATAMAGICTIMER2, 0, 0 },
47925 { "IDATACOST2", IDATACOST2, 0, 0 },
47926 { "IDATAVALIDATE2", IDATAVALIDATE2, 0, 0 },
47927 { "MESSAGEDATATEXTLEN", MESSAGEDATATEXTLEN, 0, 0 },
47928 { "LWPNFLAGS", LWPNFLAGS, 0, 0 },
47929 { "EWPNFLAGS", EWPNFLAGS, 0, 0 },
47930 { "REFSTACK", REFSTACK, 0, 0 },
47931 { "STACKSIZE", STACKSIZE, 0, 0 },
47932 { "STACKFULL", STACKFULL, 0, 0 },
47933 { "ITEMFORCEGRAB", ITEMFORCEGRAB, 0, 0 },
47934 { "COMBODTRIGGERITEM", COMBODTRIGGERITEM, 0, 0 },
47935 { "COMBODTRIGGERTIMER", COMBODTRIGGERTIMER, 0, 0 },
47936 { "COMBODTRIGGERSFX", COMBODTRIGGERSFX, 0, 0 },
47937 { "COMBODTRIGGERCHANGECMB", COMBODTRIGGERCHANGECMB, 0, 0 },
47938 { "SCREENEXSTATED", SCREENEXSTATED, 0, 0 },
47939 { "MAPDATAEXSTATED", MAPDATAEXSTATED, 0, 0 },
47940 { "HEROSTANDING", HEROSTANDING, 0, 0 },
47941 { "COMBODTRIGGERPROX", COMBODTRIGGERPROX, 0, 0 },
47942 { "COMBODTRIGGERLIGHTBEAM", COMBODTRIGGERLIGHTBEAM, 0, 0 },
47943 { "COMBODTRIGGERCTR", COMBODTRIGGERCTR, 0, 0 },
47944 { "COMBODTRIGGERCTRAMNT", COMBODTRIGGERCTRAMNT, 0, 0 },
47945 { "GENDATAEVENTSTATE", GENDATAEVENTSTATE, 0, 0 },
47946 { "GAMEEVENTDATA", GAMEEVENTDATA, 0, 0 },
47947 { "ITEMDROPPEDBY", ITEMDROPPEDBY, 0, 0 },
47948 { "GAMEGSWITCH", GAMEGSWITCH, 0, 0 },
47949
47950 { "COMBODTRIGGERCOOLDOWN", COMBODTRIGGERCOOLDOWN, 0, 0 },
47951 { "COMBODTRIGGERCOPYCAT", COMBODTRIGGERCOPYCAT, 0, 0 },
47952 { "COMBODTRIGITEMPICKUP", COMBODTRIGITEMPICKUP, 0, 0 },
47953 { "COMBODTRIGEXSTATE", COMBODTRIGEXSTATE, 0, 0 },
47954 { "COMBODTRIGSPAWNENEMY", COMBODTRIGSPAWNENEMY, 0, 0 },
47955 { "COMBODTRIGSPAWNITEM", COMBODTRIGSPAWNITEM, 0, 0 },
47956 { "COMBODTRIGCSETCHANGE", COMBODTRIGCSETCHANGE, 0, 0 },
47957 { "COMBODLIFTGFXCOMBO", COMBODLIFTGFXCOMBO, 0, 0 },
47958 { "COMBODLIFTGFXCCSET", COMBODLIFTGFXCCSET, 0, 0 },
47959 { "COMBODLIFTUNDERCMB", COMBODLIFTUNDERCMB, 0, 0 },
47960 { "COMBODLIFTUNDERCS", COMBODLIFTUNDERCS, 0, 0 },
47961 { "COMBODLIFTDAMAGE", COMBODLIFTDAMAGE, 0, 0 },
47962 { "COMBODLIFTLEVEL", COMBODLIFTLEVEL, 0, 0 },
47963 { "COMBODLIFTITEM", COMBODLIFTITEM, 0, 0 },
47964 { "COMBODLIFTFLAGS", COMBODLIFTFLAGS, 0, 0 },
47965 { "COMBODLIFTGFXTYPE", COMBODLIFTGFXTYPE, 0, 0 },
47966 { "COMBODLIFTGFXSPRITE", COMBODLIFTGFXSPRITE, 0, 0 },
47967 { "COMBODLIFTSFX", COMBODLIFTSFX, 0, 0 },
47968 { "COMBODLIFTBREAKSPRITE", COMBODLIFTBREAKSPRITE, 0, 0 },
47969 { "COMBODLIFTBREAKSFX", COMBODLIFTBREAKSFX, 0, 0 },
47970 { "COMBODLIFTHEIGHT", COMBODLIFTHEIGHT, 0, 0 },
47971 { "COMBODLIFTTIME", COMBODLIFTTIME, 0, 0 },
47972 { "CLASS_THISKEY", CLASS_THISKEY, 0, 0 },
47973 { "ZELDABETATYPE", ZELDABETATYPE, 0, 0 },
47974 { "HEROCOYOTETIME", HEROCOYOTETIME, 0, 0 },
47975 { "FFCLASTCHANGERX", FFCLASTCHANGERX, 0, 0 },
47976 { "FFCLASTCHANGERY", FFCLASTCHANGERY, 0, 0 },
47977 { "LWPNTIMEOUT", LWPNTIMEOUT, 0, 0 },
47978 { "EWPNTIMEOUT", EWPNTIMEOUT, 0, 0 },
47979 { "COMBODTRIGGERLSTATE", COMBODTRIGGERLSTATE, 0, 0 },
47980 { "COMBODTRIGGERGSTATE", COMBODTRIGGERGSTATE, 0, 0 },
47981 { "COMBODTRIGGERGTIMER", COMBODTRIGGERGTIMER, 0, 0 },
47982 { "GAMEMOUSECURSOR", GAMEMOUSECURSOR, 0, 0 },
47983 { "COMBODTRIGGERGENSCRIPT", COMBODTRIGGERGENSCRIPT, 0, 0 },
47984 { "COMBODTRIGGERGROUP", COMBODTRIGGERGROUP, 0, 0 },
47985 { "COMBODTRIGGERGROUPVAL", COMBODTRIGGERGROUPVAL, 0, 0 },
47986 { "HEROLIFTEDWPN", HEROLIFTEDWPN, 0, 0 },
47987 { "HEROLIFTTIMER", HEROLIFTTIMER, 0, 0 },
47988 { "HEROLIFTMAXTIMER", HEROLIFTMAXTIMER, 0, 0 },
47989 { "HEROLIFTHEIGHT", HEROLIFTHEIGHT, 0, 0 },
47990 { "HEROHAMMERSTATE", HEROHAMMERSTATE, 0, 0 },
47991 { "HEROLIFTFLAGS", HEROLIFTFLAGS, 0, 0 },
47992 { "COMBODLIFTWEAPONITEM", COMBODLIFTWEAPONITEM, 0, 0 },
47993 { "LWPNDEATHITEM", LWPNDEATHITEM, 0, 0 },
47994 { "LWPNDEATHDROPSET", LWPNDEATHDROPSET, 0, 0 },
47995 { "LWPNDEATHIPICKUP", LWPNDEATHIPICKUP, 0, 0 },
47996 { "LWPNDEATHSPRITE", LWPNDEATHSPRITE, 0, 0 },
47997 { "LWPNDEATHSFX", LWPNDEATHSFX, 0, 0 },
47998 { "EWPNDEATHITEM", EWPNDEATHITEM, 0, 0 },
47999 { "EWPNDEATHDROPSET", EWPNDEATHDROPSET, 0, 0 },
48000 { "EWPNDEATHIPICKUP", EWPNDEATHIPICKUP, 0, 0 },
48001 { "EWPNDEATHSPRITE", EWPNDEATHSPRITE, 0, 0 },
48002 { "EWPNDEATHSFX", EWPNDEATHSFX, 0, 0 },
48003
48004 { "REFPALDATA", REFPALDATA, 0, 0 },
48005
48006 { "PALDATACOLOR", PALDATACOLOR, 0, 0 },
48007 { "PALDATAR", PALDATAR, 0, 0 },
48008 { "PALDATAG", PALDATAG, 0, 0 },
48009 { "PALDATAB", PALDATAB, 0, 0 },
48010
48011 { "DMAPDATALOOPSTART", DMAPDATALOOPSTART, 0, 0 },
48012 { "DMAPDATALOOPEND", DMAPDATALOOPEND, 0, 0 },
48013 { "DMAPDATAXFADEIN", DMAPDATAXFADEIN, 0, 0 },
48014 { "DMAPDATAXFADEOUT", DMAPDATAXFADEOUT, 0, 0 },
48015 { "MUSICUPDATECOND", MUSICUPDATECOND, 0, 0 },
48016 { "MUSICUPDATEFLAGS", MUSICUPDATEFLAGS, 0, 0 },
48017 { "DMAPDATAINTROSTRINGID", DMAPDATAINTROSTRINGID, 0, 0 },
48018 { "IS8BITTILE", IS8BITTILE, 0, 0 },
48019 { "RESRVD_VAR_MOOSH09", RESRVD_VAR_MOOSH09, 0, 0 },
48020 { "RESRVD_VAR_MOOSH10", RESRVD_VAR_MOOSH10, 0, 0 },
48021 { "RESRVD_VAR_MOOSH11", RESRVD_VAR_MOOSH11, 0, 0 },
48022 { "RESRVD_VAR_MOOSH12", RESRVD_VAR_MOOSH12, 0, 0 },
48023 { "RESRVD_VAR_MOOSH13", RESRVD_VAR_MOOSH13, 0, 0 },
48024 { "RESRVD_VAR_MOOSH14", RESRVD_VAR_MOOSH14, 0, 0 },
48025 { "RESRVD_VAR_MOOSH15", RESRVD_VAR_MOOSH15, 0, 0 },
48026 { "RESRVD_VAR_MOOSH16", RESRVD_VAR_MOOSH16, 0, 0 },
48027 { "RESRVD_VAR_MOOSH17", RESRVD_VAR_MOOSH17, 0, 0 },
48028 { "RESRVD_VAR_MOOSH18", RESRVD_VAR_MOOSH18, 0, 0 },
48029 { "RESRVD_VAR_MOOSH19", RESRVD_VAR_MOOSH19, 0, 0 },
48030 { "RESRVD_VAR_MOOSH20", RESRVD_VAR_MOOSH20, 0, 0 },
48031 { "RESRVD_VAR_MOOSH21", RESRVD_VAR_MOOSH21, 0, 0 },
48032 { "RESRVD_VAR_MOOSH22", RESRVD_VAR_MOOSH22, 0, 0 },
48033 { "RESRVD_VAR_MOOSH23", RESRVD_VAR_MOOSH23, 0, 0 },
48034 { "RESRVD_VAR_MOOSH24", RESRVD_VAR_MOOSH24, 0, 0 },
48035 { "RESRVD_VAR_MOOSH25", RESRVD_VAR_MOOSH25, 0, 0 },
48036 { "RESRVD_VAR_MOOSH26", RESRVD_VAR_MOOSH26, 0, 0 },
48037 { "RESRVD_VAR_MOOSH27", RESRVD_VAR_MOOSH27, 0, 0 },
48038 { "RESRVD_VAR_MOOSH28", RESRVD_VAR_MOOSH28, 0, 0 },
48039 { "RESRVD_VAR_MOOSH29", RESRVD_VAR_MOOSH29, 0, 0 },
48040 { "RESRVD_VAR_MOOSH30", RESRVD_VAR_MOOSH30, 0, 0 },
48041 { "DMAPDATAMIRRDMAP", DMAPDATAMIRRDMAP, 0, 0 },
48042 { "IDATAGRADUAL", IDATAGRADUAL, 0, 0 },
48043 { "IDATASPRSCRIPT", IDATASPRSCRIPT, 0, 0 },
48044 { "IDATAPSOUND", IDATAPSOUND, 0, 0 },
48045 { "IDATACONSTSCRIPT", IDATACONSTSCRIPT, 0, 0 },
48046 { "IDATASSWIMDISABLED", IDATASSWIMDISABLED, 0, 0 },
48047 { "IDATABUNNYABLE", IDATABUNNYABLE, 0, 0 },
48048 { "IDATAJINXIMMUNE", IDATAJINXIMMUNE, 0, 0 },
48049 { "IDATAJINXSWAP", IDATAJINXSWAP, 0, 0 },
48050 { "SPRITEDATAFLCSET", SPRITEDATAFLCSET, 0, 0 },
48051 { "SPRITEDATAFLAGS", SPRITEDATAFLAGS, 0, 0 },
48052 { "SPRITEDATAID", SPRITEDATAID, 0, 0 },
48053 { "CLASS_THISKEY2", CLASS_THISKEY2, 0, 0 },
48054 { "RESRVD_VAR_Z3_01", RESRVD_VAR_Z3_01, 0, 0 },
48055 { "RESRVD_VAR_Z3_02", RESRVD_VAR_Z3_02, 0, 0 },
48056 { "RESRVD_VAR_Z3_03", RESRVD_VAR_Z3_03, 0, 0 },
48057 { "RESRVD_VAR_Z3_04", RESRVD_VAR_Z3_04, 0, 0 },
48058 { "RESRVD_VAR_Z3_05", RESRVD_VAR_Z3_05, 0, 0 },
48059 { "RESRVD_VAR_Z3_06", RESRVD_VAR_Z3_06, 0, 0 },
48060 { "RESRVD_VAR_Z3_07", RESRVD_VAR_Z3_07, 0, 0 },
48061 { "RESRVD_VAR_Z3_08", RESRVD_VAR_Z3_08, 0, 0 },
48062 { "RESRVD_VAR_Z3_09", RESRVD_VAR_Z3_09, 0, 0 },
48063 { "RESRVD_VAR_Z3_10", RESRVD_VAR_Z3_10, 0, 0 },
48064 { "RESRVD_VAR_Z3_11", RESRVD_VAR_Z3_11, 0, 0 },
48065 { "RESRVD_VAR_Z3_12", RESRVD_VAR_Z3_12, 0, 0 },
48066 { "RESRVD_VAR_Z3_13", RESRVD_VAR_Z3_13, 0, 0 },
48067 { "RESRVD_VAR_Z3_14", RESRVD_VAR_Z3_14, 0, 0 },
48068 { "RESRVD_VAR_Z3_15", RESRVD_VAR_Z3_15, 0, 0 },
48069 { "RESRVD_VAR_Z3_16", RESRVD_VAR_Z3_16, 0, 0 },
48070 { "LWPNLIFTLEVEL", LWPNLIFTLEVEL, 0, 0},
48071 { "LWPNLIFTTIME", LWPNLIFTTIME, 0, 0},
48072 { "LWPNLIFTHEIGHT", LWPNLIFTHEIGHT, 0, 0},
48073 { "EWPNLIFTLEVEL", EWPNLIFTLEVEL, 0, 0},
48074 { "EWPNLIFTTIME", EWPNLIFTTIME, 0, 0},
48075 { "EWPNLIFTHEIGHT", EWPNLIFTHEIGHT, 0, 0},
48076 { "HEROSHIELDJINX", HEROSHIELDJINX, 0, 0},
48077 { "MAPDATALENSSHOWS", MAPDATALENSSHOWS, 0, 0},
48078 { "MAPDATALENSHIDES", MAPDATALENSHIDES, 0, 0},
48079 { "SCREENLENSSHOWS", SCREENLENSSHOWS, 0, 0},
48080 { "SCREENLENSHIDES", SCREENLENSHIDES, 0, 0},
48081 { "GAMETRIGGROUPS", GAMETRIGGROUPS, 0, 0},
48082 { "GAMEOVERRIDEITEMS", GAMEOVERRIDEITEMS, 0, 0},
48083 { "DMAPDATASUBSCRO", DMAPDATASUBSCRO, 0, 0},
48084 { "REFSUBSCREENPAGE", REFSUBSCREENPAGE, 0, 0},
48085 { "REFSUBSCREENWIDG", REFSUBSCREENWIDG, 0, 0},
48086 { "SUBDATACURPG", SUBDATACURPG, 0, 0},
48087 { "SUBDATANUMPG", SUBDATANUMPG, 0, 0},
48088 { "SUBDATAPAGES", SUBDATAPAGES, 0, 0},
48089 { "SUBDATATYPE", SUBDATATYPE, 0, 0},
48090 { "SUBDATAFLAGS", SUBDATAFLAGS, 0, 0},
48091 { "SUBDATACURSORPOS", SUBDATACURSORPOS, 0, 0},
48092 { "SUBDATASCRIPT", SUBDATASCRIPT, 0, 0},
48093 { "SUBDATAINITD", SUBDATAINITD, 0, 0},
48094 { "SUBDATABTNLEFT", SUBDATABTNLEFT, 0, 0},
48095 { "SUBDATABTNRIGHT", SUBDATABTNRIGHT, 0, 0},
48096 { "SUBDATATRANSLEFTTY", SUBDATATRANSLEFTTY, 0, 0},
48097 { "SUBDATATRANSLEFTSFX", SUBDATATRANSLEFTSFX, 0, 0},
48098 { "SUBDATATRANSLEFTFLAGS", SUBDATATRANSLEFTFLAGS, 0, 0},
48099 { "SUBDATATRANSLEFTARGS", SUBDATATRANSLEFTARGS, 0, 0},
48100 { "PORTALX", PORTALX, 0, 0},
48101 { "PORTALY", PORTALY, 0, 0},
48102 { "PORTALDMAP", PORTALDMAP, 0, 0},
48103 { "PORTALSCREEN", PORTALSCREEN, 0, 0},
48104 { "PORTALACLK", PORTALACLK, 0, 0},
48105 { "PORTALAFRM", PORTALAFRM, 0, 0},
48106 { "PORTALOTILE", PORTALOTILE, 0, 0},
48107 { "PORTALASPD", PORTALASPD, 0, 0},
48108 { "PORTALFRAMES", PORTALFRAMES, 0, 0},
48109 { "PORTALSAVED", PORTALSAVED, 0, 0},
48110 { "PORTALCLOSEDIS", PORTALCLOSEDIS, 0, 0},
48111 { "REFPORTAL", REFPORTAL, 0, 0},
48112 { "REFSAVPORTAL", REFSAVPORTAL, 0, 0},
48113 { "PORTALWARPSFX", PORTALWARPSFX, 0, 0},
48114 { "PORTALWARPVFX", PORTALWARPVFX, 0, 0},
48115 { "SAVEDPORTALX", SAVEDPORTALX, 0, 0},
48116 { "SAVEDPORTALY", SAVEDPORTALY, 0, 0},
48117 { "SAVEDPORTALSRCDMAP", SAVEDPORTALSRCDMAP, 0, 0},
48118 { "SAVEDPORTALDESTDMAP", SAVEDPORTALDESTDMAP, 0, 0},
48119 { "SAVEDPORTALSRCSCREEN", SAVEDPORTALSRCSCREEN, 0, 0},
48120 { "SAVEDPORTALWARPSFX", SAVEDPORTALWARPSFX, 0, 0},
48121 { "SAVEDPORTALWARPVFX", SAVEDPORTALWARPVFX, 0, 0},
48122 { "SAVEDPORTALSPRITE", SAVEDPORTALSPRITE, 0, 0},
48123 { "SAVEDPORTALPORTAL", SAVEDPORTALPORTAL, 0, 0},
48124 { "PORTALCOUNT", PORTALCOUNT, 0, 0},
48125 { "SAVEDPORTALCOUNT", SAVEDPORTALCOUNT, 0, 0},
48126 { "SAVEDPORTALDSTSCREEN", SAVEDPORTALDSTSCREEN, 0, 0},
48127
48128 { "SUBDATATRANSRIGHTTY", SUBDATATRANSRIGHTTY, 0, 0 },
48129 { "SUBDATATRANSRIGHTSFX", SUBDATATRANSRIGHTSFX, 0, 0 },
48130 { "SUBDATATRANSRIGHTFLAGS", SUBDATATRANSRIGHTFLAGS, 0, 0 },
48131 { "SUBDATATRANSRIGHTARGS", SUBDATATRANSRIGHTARGS, 0, 0 },
48132 { "SUBDATASELECTORDSTX", SUBDATASELECTORDSTX, 0, 0 },
48133 { "SUBDATASELECTORDSTY", SUBDATASELECTORDSTY, 0, 0 },
48134 { "SUBDATASELECTORDSTW", SUBDATASELECTORDSTW, 0, 0 },
48135 { "SUBDATASELECTORDSTH", SUBDATASELECTORDSTH, 0, 0 },
48136 { "SUBDATASELECTORWID", SUBDATASELECTORWID, 0, 0 },
48137 { "SUBDATASELECTORHEI", SUBDATASELECTORHEI, 0, 0 },
48138 { "SUBDATASELECTORTILE", SUBDATASELECTORTILE, 0, 0 },
48139 { "SUBDATASELECTORCSET", SUBDATASELECTORCSET, 0, 0 },
48140 { "SUBDATASELECTORFRM", SUBDATASELECTORFRM, 0, 0 },
48141 { "SUBDATASELECTORASPD", SUBDATASELECTORASPD, 0, 0 },
48142 { "SUBDATASELECTORDELAY", SUBDATASELECTORDELAY, 0, 0 },
48143 { "SUBDATATRANSCLK", SUBDATATRANSCLK, 0, 0 },
48144 { "SUBDATATRANSTY", SUBDATATRANSTY, 0, 0 },
48145 { "SUBDATATRANSFLAGS", SUBDATATRANSFLAGS, 0, 0 },
48146 { "SUBDATATRANSARGS", SUBDATATRANSARGS, 0, 0 },
48147 { "SUBDATATRANSFROMPG", SUBDATATRANSFROMPG, 0, 0 },
48148 { "SUBDATATRANSTOPG", SUBDATATRANSTOPG, 0, 0 },
48149 { "SUBDATASELECTORFLASHCSET", SUBDATASELECTORFLASHCSET, 0, 0 },
48150 { "GAMEASUBOPEN", GAMEASUBOPEN, 0, 0 },
48151 { "GAMENUMASUB", GAMENUMASUB, 0, 0 },
48152 { "GAMENUMPSUB", GAMENUMPSUB, 0, 0 },
48153 { "GAMENUMOSUB", GAMENUMOSUB, 0, 0 },
48154 { "SUBPGINDEX", SUBPGINDEX, 0, 0 },
48155 { "SUBPGNUMWIDG", SUBPGNUMWIDG, 0, 0 },
48156 { "SUBPGWIDGETS", SUBPGWIDGETS, 0, 0 },
48157 { "SUBPGSUBDATA", SUBPGSUBDATA, 0, 0 },
48158 { "SUBPGCURSORPOS", SUBPGCURSORPOS, 0, 0 },
48159 { "SUBWIDGTYPE", SUBWIDGTYPE, 0, 0 },
48160 { "SUBWIDGINDEX", SUBWIDGINDEX, 0, 0 },
48161 { "SUBWIDGPAGE", SUBWIDGPAGE, 0, 0 },
48162 { "SUBWIDGPOS", SUBWIDGPOS, 0, 0 },
48163 { "SUBWIDGPOSES", SUBWIDGPOSES, 0, 0 },
48164 { "SUBWIDGPOSFLAG", SUBWIDGPOSFLAG, 0, 0 },
48165 { "SUBWIDGX", SUBWIDGX, 0, 0 },
48166 { "SUBWIDGY", SUBWIDGY, 0, 0 },
48167 { "SUBWIDGW", SUBWIDGW, 0, 0 },
48168 { "SUBWIDGH", SUBWIDGH, 0, 0 },
48169 { "SUBWIDGGENFLAG", SUBWIDGGENFLAG, 0, 0 },
48170 { "SUBWIDGFLAG", SUBWIDGFLAG, 0, 0 },
48171 { "SUBWIDGSELECTORDSTX", SUBWIDGSELECTORDSTX, 0, 0 },
48172 { "SUBWIDGSELECTORDSTY", SUBWIDGSELECTORDSTY, 0, 0 },
48173 { "SUBWIDGSELECTORDSTW", SUBWIDGSELECTORDSTW, 0, 0 },
48174 { "SUBWIDGSELECTORDSTH", SUBWIDGSELECTORDSTH, 0, 0 },
48175 { "SUBWIDGSELECTORWID", SUBWIDGSELECTORWID, 0, 0 },
48176 { "SUBWIDGSELECTORHEI", SUBWIDGSELECTORHEI, 0, 0 },
48177 { "SUBWIDGSELECTORTILE", SUBWIDGSELECTORTILE, 0, 0 },
48178
48179 { "SUBWIDGSELECTORCSET", SUBWIDGSELECTORCSET, 0, 0 },
48180 { "SUBWIDGSELECTORFLASHCSET", SUBWIDGSELECTORFLASHCSET, 0, 0 },
48181 { "SUBWIDGSELECTORFRM", SUBWIDGSELECTORFRM, 0, 0 },
48182 { "SUBWIDGSELECTORASPD", SUBWIDGSELECTORASPD, 0, 0 },
48183 { "SUBWIDGSELECTORDELAY", SUBWIDGSELECTORDELAY, 0, 0 },
48184 { "SUBWIDGPRESSSCRIPT", SUBWIDGPRESSSCRIPT, 0, 0 },
48185 { "SUBWIDGPRESSINITD", SUBWIDGPRESSINITD, 0, 0 },
48186 { "SUBWIDGBTNPRESS", SUBWIDGBTNPRESS, 0, 0 },
48187 { "SUBWIDGBTNPG", SUBWIDGBTNPG, 0, 0 },
48188 { "SUBWIDGPGMODE", SUBWIDGPGMODE, 0, 0 },
48189 { "SUBWIDGPGTARG", SUBWIDGPGTARG, 0, 0 },
48190 { "SUBWIDGTRANSPGTY", SUBWIDGTRANSPGTY, 0, 0 },
48191 { "SUBWIDGTRANSPGSFX", SUBWIDGTRANSPGSFX, 0, 0 },
48192 { "SUBWIDGTRANSPGFLAGS", SUBWIDGTRANSPGFLAGS, 0, 0 },
48193 { "SUBWIDGTRANSPGARGS", SUBWIDGTRANSPGARGS, 0, 0 },
48194
48195 { "SUBWIDGTY_CSET", SUBWIDGTY_CSET, 0, 0 },
48196 { "SUBWIDGTY_TILE", SUBWIDGTY_TILE, 0, 0 },
48197
48198 { "SUBWIDGTY_FONT", SUBWIDGTY_FONT, 0, 0 },
48199 { "SUBWIDGTY_ALIGN", SUBWIDGTY_ALIGN, 0, 0 },
48200 { "SUBWIDGTY_SHADOWTY", SUBWIDGTY_SHADOWTY, 0, 0 },
48201 { "SUBWIDGTY_COLOR_TXT", SUBWIDGTY_COLOR_TXT, 0, 0 },
48202 { "SUBWIDGTY_COLOR_SHD", SUBWIDGTY_COLOR_SHD, 0, 0 },
48203 { "SUBWIDGTY_COLOR_BG", SUBWIDGTY_COLOR_BG, 0, 0 },
48204
48205 { "SUBWIDGTY_COLOR_OLINE", SUBWIDGTY_COLOR_OLINE, 0, 0 },
48206 { "SUBWIDGTY_COLOR_FILL", SUBWIDGTY_COLOR_FILL, 0, 0 },
48207
48208 { "SUBWIDGTY_BUTTON", SUBWIDGTY_BUTTON, 0, 0 },
48209 { "SUBWIDGTY_COUNTERS", SUBWIDGTY_COUNTERS, 0, 0 },
48210 { "SUBWIDGTY_MINDIG", SUBWIDGTY_MINDIG, 0, 0 },
48211 { "SUBWIDGTY_MAXDIG", SUBWIDGTY_MAXDIG, 0, 0 },
48212 { "SUBWIDGTY_INFITM", SUBWIDGTY_INFITM, 0, 0 },
48213 { "SUBWIDGTY_INFCHAR", SUBWIDGTY_INFCHAR, 0, 0 },
48214 { "SUBWIDGTY_COSTIND", SUBWIDGTY_COSTIND, 0, 0 },
48215
48216 { "SUBWIDGTY_COLOR_PLAYER", SUBWIDGTY_COLOR_PLAYER, 0, 0 },
48217 { "SUBWIDGTY_COLOR_CMPBLNK", SUBWIDGTY_COLOR_CMPBLNK, 0, 0 },
48218 { "SUBWIDGTY_COLOR_CMPOFF", SUBWIDGTY_COLOR_CMPOFF, 0, 0 },
48219 { "SUBWIDGTY_COLOR_ROOM", SUBWIDGTY_COLOR_ROOM, 0, 0 },
48220 { "SUBWIDGTY_ITEMCLASS", SUBWIDGTY_ITEMCLASS, 0, 0 },
48221 { "SUBWIDGTY_ITEMID", SUBWIDGTY_ITEMID, 0, 0 },
48222 { "SUBWIDGTY_FRAMETILE", SUBWIDGTY_FRAMETILE, 0, 0 },
48223 { "SUBWIDGTY_FRAMECSET", SUBWIDGTY_FRAMECSET, 0, 0 },
48224 { "SUBWIDGTY_PIECETILE", SUBWIDGTY_PIECETILE, 0, 0 },
48225 { "SUBWIDGTY_PIECECSET", SUBWIDGTY_PIECECSET, 0, 0 },
48226 { "SUBWIDGTY_FLIP", SUBWIDGTY_FLIP, 0, 0 },
48227 { "SUBWIDGTY_NUMBER", SUBWIDGTY_NUMBER, 0, 0 },
48228 { "SUBWIDGTY_CORNER", SUBWIDGTY_CORNER, 0, 0 },
48229
48230 { "SUBWIDGTY_FRAMES", SUBWIDGTY_FRAMES, 0, 0 },
48231 { "SUBWIDGTY_SPEED", SUBWIDGTY_SPEED, 0, 0 },
48232 { "SUBWIDGTY_DELAY", SUBWIDGTY_DELAY, 0, 0 },
48233 { "SUBWIDGTY_CONTAINER", SUBWIDGTY_CONTAINER, 0, 0 },
48234 { "SUBWIDGTY_GAUGE_WID", SUBWIDGTY_GAUGE_WID, 0, 0 },
48235 { "SUBWIDGTY_GAUGE_HEI", SUBWIDGTY_GAUGE_HEI, 0, 0 },
48236 { "SUBWIDGTY_UNITS", SUBWIDGTY_UNITS, 0, 0 },
48237 { "SUBWIDGTY_HSPACE", SUBWIDGTY_HSPACE, 0, 0 },
48238 { "SUBWIDGTY_VSPACE", SUBWIDGTY_VSPACE, 0, 0 },
48239 { "SUBWIDGTY_GRIDX", SUBWIDGTY_GRIDX, 0, 0 },
48240 { "SUBWIDGTY_GRIDY", SUBWIDGTY_GRIDY, 0, 0 },
48241 { "SUBWIDGTY_ANIMVAL", SUBWIDGTY_ANIMVAL, 0, 0 },
48242 { "SUBWIDGTY_SHOWDRAIN", SUBWIDGTY_SHOWDRAIN, 0, 0 },
48243 { "SUBWIDGTY_PERCONTAINER", SUBWIDGTY_PERCONTAINER, 0, 0 },
48244 { "SUBWIDGTY_TABSIZE", SUBWIDGTY_TABSIZE, 0, 0 },
48245
48246 { "GAMEASUBYOFF", GAMEASUBYOFF, 0, 0 },
48247
48248 { "SUBWIDGDISPITM", SUBWIDGDISPITM, 0, 0 },
48249 { "SUBWIDGEQPITM", SUBWIDGEQPITM, 0, 0 },
48250
48251 { "SUBWIDG_DISPX", SUBWIDG_DISPX, 0, 0 },
48252 { "SUBWIDG_DISPY", SUBWIDG_DISPY, 0, 0 },
48253 { "SUBWIDG_DISPW", SUBWIDG_DISPW, 0, 0 },
48254 { "SUBWIDG_DISPH", SUBWIDG_DISPH, 0, 0 },
48255
48256 { "SCREENSCRDATASIZE", SCREENSCRDATASIZE, 0, 0 },
48257 { "SCREENSCRDATA", SCREENSCRDATA, 0, 0 },
48258 { "MAPDATASCRDATASIZE", MAPDATASCRDATASIZE, 0, 0 },
48259 { "MAPDATASCRDATA", MAPDATASCRDATA, 0, 0 },
48260
48261 { "HEROSHOVEOFFSET", HEROSHOVEOFFSET, 0, 0 },
48262
48263 { "SCREENDATAGUYCOUNT", SCREENDATAGUYCOUNT, 0, 0 },
48264 { "MAPDATAGUYCOUNT", MAPDATAGUYCOUNT, 0, 0 },
48265
48266 { " ", -1, 0, 0 }
48267 };
48268
48269
48270
48271 ///----------------------------------------------------------------------------------------------------//
48272 //Debugger and Logging Consoles
48273
48274 template <typename ...Params>
48275 void FFScript::ZScriptConsole(int32_t attributes,const char *format, Params&&... params)
48276 {
48277 //if ( open )
48278 {
48279 zscript_coloured_console.Create("ZQuest Classic Logging Console", 600, 200, NULL, NULL);
48280 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
48281 zscript_coloured_console.gotoxy(0,0);
48282 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48283 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Classic Logging Console\n");
48284
48285 zscript_coloured_console.cprintf( attributes, format, std::forward<Params>(params)...);
48286 }
48287 //else
48288 //{
48289 //close
48290 // zscript_coloured_console.Close();
48291 //}
48292 }
48293
48294 123 void clearConsole()
48295 {
48296 123 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
48297 123 zscript_coloured_console.gotoxy(0,0);
48298
48299 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48300 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"\n _____ ____ __ \n");
48301 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48302 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," /__ / / __ \\__ _____ _____/ /_\n");
48303 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48304 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," / / / / / / / / / _ \\/ ___/ __/\n");
48305 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48306 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," / /__/ /_/ / /_/ / __(__ ) /_ \n");
48307 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48308 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," /____/\\___\\_\\__,_/\\___/____/\\__/\n\n");
48309
48310 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48311 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Data Logging & ZScript Debug Console\n");
48312
48313 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48314 123 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Running: %s\n", getProgramVerStr());
48315
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 8 times.
123 if ( FFCore.getQuestHeaderInfo(vZelda) > 0 )
48316 {
48317 8 char const* verstr = QHeader.getVerStr();
48318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(verstr[0])
48319 {
48320 8 auto vercmp = QHeader.compareVer();
48321 8 auto astatecmp = compare(int32_t(QHeader.getAlphaState()), ALPHA_STATE);
48322 8 auto avercmp = compare(QHeader.getAlphaVer(), ALPHA_VER);
48323 8 auto timecmp = QHeader.compareDate();
48324
5/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 2 times.
8 if(!(vercmp || astatecmp || avercmp))
48325 {
48326
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!timecmp || !QHeader.new_version_is_nightly)
48327 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48328 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in this build\n", verstr);
48329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 else if(timecmp < 0)
48330 {
48331 2 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48332 2 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in an earlier nightly of the same build\n", verstr);
48333 2 }
48334 else
48335 {
48336 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48337 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in an LATER nightly of the same build!\n"
48338 "This may be unsafe to play in this version!\n", verstr);
48339 }
48340 2 }
48341 6 else zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48342 6 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in: %s\n", verstr);
48343 8 }
48344 8 }
48345 123 }
48346 void FFScript::ZScriptConsole(bool open)
48347 {
48348 if ( open )
48349 {
48350 zscript_coloured_console.Create("ZScript Debug Console", 600, 200, NULL, NULL);
48351 clearConsole();
48352 zscript_debugger = 1;
48353 }
48354 else
48355 {
48356 zscript_coloured_console.Close();
48357 zscript_debugger = 0;
48358 }
48359 zc_set_config("CONSOLE","ZScript_Debugger",zscript_debugger);
48360 }
48361
48362 void FFScript::ZASMPrint(bool open)
48363 {
48364 if(SKIPZASMPRINT()) return;
48365 zprint("%s ZASM Console\n", open ? "Opening" : "Closing");
48366 if ( open )
48367 {
48368 coloured_console.Create("ZASM Debugger", 600, 200, NULL, NULL);
48369 coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
48370 coloured_console.gotoxy(0,0);
48371 coloured_console.safeprint( CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48372 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZASM Stack Trace:\n");
48373 //coloured_console.SetAsDefaultOutput();
48374 zasm_debugger = 1;
48375 zasm_break_mode = ZASM_BREAK_HALT;
48376 }
48377 else
48378 {
48379 //close
48380 coloured_console.Close();
48381 zasm_debugger = 0;
48382 }
48383 zc_set_config("CONSOLE","print_ZASM",zasm_debugger);
48384 }
48385
48386 std::string ZASMVarToString(int32_t arg)
48387 {
48388 for(int32_t q = 0; ZASMVars[q].id != -1; ++q)
48389 {
48390 if(ZASMVars[q].maxcount>0)
48391 {
48392 int32_t start = ZASMVars[q].id;
48393 int32_t mult = zc_max(1,ZASMVars[q].multiple);
48394 if(arg >= start && arg < start+(ZASMVars[q].maxcount*mult))
48395 {
48396 for(int32_t w = 0; w < ZASMVars[q].maxcount; ++w)
48397 {
48398 if(arg!=start+(w*mult)) continue;
48399
48400 char buf[64+1];
48401 if(strcmp(ZASMVars[q].name, "A")==0)
48402 sprintf(buf, "%s%d", ZASMVars[q].name, w+1);
48403 else sprintf(buf, "%s%d", ZASMVars[q].name, w);
48404 return string(buf);
48405 }
48406 }
48407 }
48408 else if(ZASMVars[q].id == arg) return string(ZASMVars[q].name);
48409 }
48410 return "(null)";
48411 }
48412
48413 void FFScript::ZASMPrintCommand(const word scommand)
48414 {
48415 if(SKIPZASMPRINT()) return;
48416 //if ( !zasm_debugger ) return;
48417
48418 script_command s_c = ZASMcommands[scommand];
48419
48420 if(s_c.args == 2)
48421 {
48422 coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48423 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%14s: ", s_c.name);
48424
48425 if(s_c.arg1_type == 0)
48426 {
48427 coloured_console.cprintf( CConsoleLoggerEx::COLOR_WHITE |
48428 //CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %9d), ", s_v.name, get_register(sarg1));
48429 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"\t %s (val = %2d), ", ZASMVarToString(sarg1).c_str(), get_register(sarg1));
48430 }
48431 else
48432 {
48433 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED |CConsoleLoggerEx::COLOR_INTENSITY |
48434 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %2d), ", "immediate", sarg1);
48435 }
48436 if(s_c.arg2_type == 0)
48437 {
48438 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
48439 //CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %9d)\n", s_v.name, get_register(sarg2));
48440 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK, "\t %s (val = %2d)\n", ZASMVarToString(sarg2).c_str(), get_register(sarg2));
48441 }
48442 else
48443 {
48444 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
48445 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %2d)\n", "immediate", sarg2);
48446 }
48447 }
48448 else if(s_c.args == 1)
48449 {
48450 coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48451 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%14s: ", s_c.name);
48452
48453 if(s_c.arg1_type == 0)
48454 {
48455 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
48456 //CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %9d)\n", s_v.name, get_register(sarg1));
48457 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"\t %w (val = %2d)\n", ZASMVarToString(sarg1).c_str(), get_register(sarg1));
48458 }
48459 else
48460 {
48461 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
48462 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %2d)\n", "immediate", sarg1);
48463 }
48464 }
48465 else
48466 {
48467 coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48468 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%14s\n",s_c.name);
48469 }
48470 //s_c.name is the string with the instruction
48471
48472 //coloured_console.print();
48473 }
48474
48475 void FFScript::ZASMPrintVarSet(const int32_t arg, int32_t argval)
48476 {
48477 if(SKIPZASMPRINT()) return;
48478
48479 //if ( !zasm_debugger ) return;
48480 // script_variable s_v = ZASMVars[arg];
48481 //s_v.name is the string with the instruction
48482 coloured_console.cprintf( CConsoleLoggerEx::COLOR_WHITE |
48483 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Set: %s\t",ZASMVarToString(arg).c_str());
48484 coloured_console.cprintf( CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48485 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%d\n",argval);
48486 //coloured_console.print();
48487 }
48488
48489 void FFScript::ZASMPrintVarGet(const int32_t arg, int32_t argval)
48490 {
48491 if(SKIPZASMPRINT()) return;
48492
48493 //if ( !zasm_debugger ) return;
48494 // script_variable s_v = ZASMVars[arg];
48495 //s_v.name is the string with the instruction
48496 coloured_console.cprintf( CConsoleLoggerEx::COLOR_WHITE |
48497 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Get: %s\t",ZASMVarToString(arg).c_str());
48498 coloured_console.cprintf( CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48499 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%d\n",argval);
48500 //coloured_console.print();
48501 }
48502
48503
48504
48505 ///----------------------------------------------------------------------------------------------------//
48506 //Tracing
48507
48508 3553 void FFScript::do_trace(bool v)
48509 {
48510
5/14
✗ Branch 0 not taken.
✓ Branch 1 taken 3553 times.
✓ Branch 2 taken 3553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3553 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3553 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3553 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
7106 bool should_replay_trace = replay_is_active() && replay_get_meta_bool("script_trace");
48511 // For now, only prevent tracing to allegro log for Web version. Some quests may expect players to
48512 // look in the logs for spoiler/secret stuff.
48513 #ifdef __EMSCRIPTEN__
48514 bool should_trace = zscript_debugger || should_replay_trace;
48515 if (!should_trace) return;
48516 #endif
48517
48518 3553 int32_t temp = SH::get_arg(sarg1, v);
48519
48520 char tmp[100];
48521
1/2
✓ Branch 0 taken 3553 times.
✗ Branch 1 not taken.
3553 sprintf(tmp, (temp < 0 ? "%06d" : "%05d"), temp);
48522
1/2
✓ Branch 0 taken 3553 times.
✗ Branch 1 not taken.
3553 string s2(tmp);
48523
5/10
✓ Branch 0 taken 3553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3553 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3553 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3553 times.
✗ Branch 9 not taken.
3553 s2 = s2.substr(0, s2.size() - 4) + "." + s2.substr(s2.size() - 4, 4) + "\n";
48524
1/2
✓ Branch 0 taken 3553 times.
✗ Branch 1 not taken.
3553 TraceScriptIDs();
48525
1/2
✓ Branch 0 taken 3553 times.
✗ Branch 1 not taken.
3553 al_trace("%s", s2.c_str());
48526
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3544 times.
3553 if (should_replay_trace)
48527
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 replay_step_comment("trace: " + s2);
48528
48529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3553 times.
3553 if ( zscript_debugger )
48530 {
48531 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
48532 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),s2.c_str());
48533 }
48534 3553 }
48535 void FFScript::do_tracel(bool v)
48536 {
48537 int32_t temp = SH::get_arg(sarg1, v);
48538
48539 char tmp[32];
48540 sprintf(tmp, "%d\n", temp);
48541 TraceScriptIDs();
48542 al_trace("%s", tmp);
48543 if (replay_is_active() && replay_get_meta_bool("script_trace"))
48544 replay_step_comment(fmt::format("trace: {}", temp));
48545
48546 if ( zscript_debugger )
48547 {
48548 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
48549 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),tmp);
48550 }
48551 }
48552
48553 void FFScript::do_tracebool(const bool v)
48554 {
48555 int32_t temp = SH::get_arg(sarg1, v);
48556 TraceScriptIDs();
48557 char const* str = temp ? "true\n" : "false\n";
48558 al_trace("%s", str);
48559 if (replay_is_active() && replay_get_meta_bool("script_trace"))
48560 replay_step_comment(fmt::format("trace: {}", (bool)temp));
48561
48562 if ( zscript_debugger )
48563 {
48564 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
48565 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str);
48566 }
48567 }
48568
48569 3990 void traceStr(string const& str)
48570 {
48571 3990 FFCore.TraceScriptIDs();
48572 3990 safe_al_trace(str);
48573
7/16
✗ Branch 0 not taken.
✓ Branch 1 taken 3990 times.
✓ Branch 2 taken 3990 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3990 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3990 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3990 times.
✓ Branch 10 taken 671 times.
✓ Branch 11 taken 3319 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
7980 if (replay_is_active() && replay_get_meta_bool("script_trace"))
48574
1/2
✓ Branch 0 taken 3319 times.
✗ Branch 1 not taken.
3319 replay_step_comment("trace: " + str);
48575
48576
1/2
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
3990 if ( zscript_debugger )
48577 {
48578 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
48579 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str.c_str());
48580 }
48581 3990 }
48582
48583 384 void FFScript::do_tracestring()
48584 {
48585 384 int32_t arrayptr = get_register(sarg1) / 10000;
48586 384 string str;
48587
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ArrayH::getString(arrayptr, str, 512);
48588
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 str += "\0"; //In the event that the user passed an array w/o NULL, don't crash.
48589
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 traceStr(str);
48590 384 }
48591
48592 bool is_valid_format(char c)
48593 {
48594 switch(c)
48595 {
48596 case 'f': case 'd': case 'i': case 'p':
48597 case 'l': case 's': case 'c': case 'X':
48598 case 'x': case 'b': case 'B': case 'a':
48599 return true;
48600 }
48601 return false;
48602 }
48603 #define FORMATTER_FLAG_0FILL 0x01
48604 18977 char const* zs_formatter(char const* format, int32_t arg, int32_t mindig, dword flags)
48605 {
48606
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 18974 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
18977 static std::string ret;
48607
48608 18977 ret.clear();
48609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18977 times.
18977 if(format)
48610 {
48611 37954 std::string mdstr = fmt::format("%{}{}{}",(flags&FORMATTER_FLAG_0FILL)?"0":"",
48612
2/4
✓ Branch 0 taken 18977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18977 times.
18977 mindig, (format[0] == 'x' || format[0] == 'X') ? format[0] : 'd');
48613 18977 char const* mindigbuf = mdstr.c_str();
48614 18977 bool tempbool = false;
48615
2/12
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 18219 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 758 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
18977 switch(format[0])
48616 {
48617 case 'f':
48618 tempbool = true;
48619 [[fallthrough]];
48620 case 'd':
48621
2/2
✓ Branch 0 taken 17747 times.
✓ Branch 1 taken 472 times.
18691 if(arg%10000)
48622 472 tempbool = true;
48623 [[fallthrough]];
48624 case 'i':
48625 case 'p':
48626 {
48627 18219 char argbuf[32] = {0};
48628 18219 bool neg = arg < 0;
48629
1/2
✓ Branch 0 taken 18219 times.
✗ Branch 1 not taken.
18219 if(mindig)
48630 sprintf(argbuf,mindigbuf,arg / 10000);
48631
1/2
✓ Branch 0 taken 18219 times.
✗ Branch 1 not taken.
18219 else zc_itoa(arg / 10000, argbuf);
48632
48633
2/2
✓ Branch 0 taken 17747 times.
✓ Branch 1 taken 472 times.
18219 if(tempbool) //add decimal places
48634 {
48635 472 arg = abs(arg);
48636 472 auto ind = strlen(argbuf);
48637 472 argbuf[ind++] = '.';
48638
2/2
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 472 times.
2360 for(int div = 1000; div > 0; div /= 10)
48639 1888 argbuf[ind++] = '0' + (arg/div)%10;
48640
4/4
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 244 times.
✓ Branch 3 taken 472 times.
716 for(--ind; argbuf[ind]=='0' && argbuf[ind-1]!='-'; --ind)
48641 {
48642 244 argbuf[ind] = 0;
48643 244 }
48644 472 }
48645
48646
4/4
✓ Branch 0 taken 929 times.
✓ Branch 1 taken 17290 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 877 times.
18219 if(neg && argbuf[0] != '-')
48647
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 ret = "-";
48648
1/2
✓ Branch 0 taken 18219 times.
✗ Branch 1 not taken.
18219 ret += argbuf;
48649 18219 return ret.c_str();
48650 }
48651 //
48652 case 'l':
48653 {
48654 char argbuf[32] = {0};
48655 if(mindig)
48656 sprintf(argbuf, mindigbuf, arg);
48657 else zc_itoa(arg, argbuf);
48658
48659 ret = argbuf;
48660 return ret.c_str();
48661 }
48662 //
48663 case 's':
48664 {
48665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 758 times.
758 if(mindig)
48666 Z_scripterrlog("Cannot use minimum digits flag for '%%s'\n");
48667
1/2
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
758 if(arg)
48668 {
48669 758 int32_t strptr = (arg / 10000);
48670
1/2
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
758 ArrayManager am(strptr);
48671
2/4
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 758 times.
758 if(am.invalid())
48672 ret = "<INVALID STRING>";
48673
1/2
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
758 else ArrayH::getString(strptr, ret, MAX_ZC_ARRAY_SIZE);
48674 758 }
48675 else ret = "<NULL>";
48676 758 return ret.c_str();
48677 }
48678 case 'c':
48679 {
48680 if(mindig)
48681 Z_scripterrlog("Cannot use minimum digits flag for '%%c'\n");
48682 int32_t c = (arg / 10000);
48683 if ( (char(c)) != c )
48684 {
48685 Z_scripterrlog("Illegal char value (%d) passed to sprintf as '%%c' arg\n", c);
48686 Z_scripterrlog("Value of invalid char will overflow.\n");
48687 }
48688 ret.push_back(char(c));
48689 return ret.c_str();
48690 }
48691 //
48692 case 'X':
48693 tempbool = true;
48694 [[fallthrough]];
48695 case 'x':
48696 {
48697 char argbuf[32] = {0};
48698 if(mindig)
48699 sprintf(argbuf,mindigbuf,arg / 10000);
48700 else zc_itoa( (arg/10000), argbuf, 16 ); //base 16; hex
48701
48702 for ( int32_t inx = 0; inx < 16; ++inx ) //set chosen caps
48703 {
48704 argbuf[inx] = ( tempbool ? toupper(argbuf[inx]) : tolower(argbuf[inx]) );
48705 }
48706 ret = "0x";
48707 ret += argbuf;
48708 return ret.c_str();
48709 }
48710 //
48711 case 'b': //int binary
48712 arg /= 10000;
48713 [[fallthrough]];
48714 case 'B': //long binary
48715 {
48716 char argbuf[33] = {0};
48717 int num_digits = mindig;
48718 for(int q = num_digits; q < 32; ++q)
48719 if(arg&(1<<q))
48720 num_digits = q+1;
48721 for(int q = 0; q < num_digits; ++q)
48722 {
48723 argbuf[q] = (arg&(1<<(num_digits-q-1)))
48724 ? '1' : '0';
48725 }
48726 ret = argbuf;
48727 return ret.c_str();
48728 }
48729 case 'a': //array
48730 {
48731 if(arg)
48732 {
48733 if(!is_valid_format(format[1]))
48734 {
48735 Z_scripterrlog("Format '%%a%c' is invalid!\n",format[1]);
48736 break;
48737 }
48738 ArrayManager am(arg/10000);
48739 ret = am.asString([&](int32_t val)
48740 {
48741 return zs_formatter(format+1, val, mindig, flags);
48742 }, 214748);
48743 }
48744 else ret = "{ NULL }";
48745 return ret.c_str();
48746 }
48747 default:
48748 {
48749 Z_scripterrlog("Error: '%%%c' is not a valid printf argument.\n",format[0]);
48750 return ret.c_str();
48751 }
48752 }
48753
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 18977 times.
✗ Branch 2 not taken.
18977 }
48754 Z_scripterrlog("Error: No format parameter given for zs_formatter\n");
48755 return ret.c_str();
48756 18977 }
48757
48758 5376 static int32_t zspr_varg_getter(int32_t,int32_t next_arg)
48759 {
48760 5376 return zs_vargs.at(next_arg);
48761 }
48762 13601 static int32_t zspr_stack_getter(int32_t num_args, int32_t next_arg)
48763 {
48764 13601 return SH::read_stack(((ri->sp + num_args) - 1) - next_arg);
48765 }
48766 10489 string zs_sprintf(char const* format, int32_t num_args, std::function<int32_t(int32_t,int32_t)> arg_getter)
48767 {
48768 10489 int32_t next_arg = 0;
48769 10489 bool is_old_args = get_qr(qr_OLD_PRINTF_ARGS);
48770 10489 ostringstream oss;
48771
2/2
✓ Branch 0 taken 6856 times.
✓ Branch 1 taken 22610 times.
29466 while(format[0] != '\0')
48772 {
48773 22610 int32_t arg_val = 0;
48774
2/2
✓ Branch 0 taken 18977 times.
✓ Branch 1 taken 3633 times.
22610 if(next_arg < num_args)
48775 {
48776
1/2
✓ Branch 0 taken 18977 times.
✗ Branch 1 not taken.
18977 arg_val = arg_getter(num_args,next_arg);
48777 18977 }
48778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3633 times.
3633 else if(get_qr(qr_PRINTF_NO_0FILL))
48779 {
48780 oss << format;
48781 return oss.str();
48782 }
48783 22610 char buf[256] = {0};
48784
2/2
✓ Branch 0 taken 18977 times.
✓ Branch 1 taken 76591 times.
95568 for ( int32_t q = 0; q < 256; ++q )
48785 {
48786
2/2
✓ Branch 0 taken 3633 times.
✓ Branch 1 taken 72958 times.
76591 if(format[0] == '\0') //done
48787 {
48788
1/2
✓ Branch 0 taken 3633 times.
✗ Branch 1 not taken.
3633 oss << buf;
48789
1/2
✓ Branch 0 taken 3633 times.
✗ Branch 1 not taken.
3633 return oss.str();
48790 }
48791
2/2
✓ Branch 0 taken 19292 times.
✓ Branch 1 taken 53666 times.
72958 else if(format[0] == '%')
48792 {
48793 19292 ++format;
48794 19292 int32_t min_digits = 0;
48795 19292 dword formatter_flags = 0;
48796
3/6
✓ Branch 0 taken 18977 times.
✓ Branch 1 taken 315 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18977 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
19292 if(format[0] >= '0' && format[0] <= '9' && !is_old_args)
48797 {
48798 char argbuf[4] = {0};
48799 int32_t q = 0;
48800 if(format[0] == '0') //Leading 0 means to 0-fill, and gets eaten
48801 formatter_flags |= FORMATTER_FLAG_0FILL;
48802 else --format; //else don't eat
48803 while(q < 4)
48804 {
48805 ++format;
48806 char c = format[0];
48807 if(c == '\0')
48808 {
48809 Z_scripterrlog("Cannot use minimum digits flag with no argument\n");
48810 oss << buf;
48811 return oss.str();
48812 }
48813 if(c >= '0' && c <= '9')
48814 argbuf[q++] = c;
48815 else
48816 {
48817 --format;
48818 break;
48819 }
48820 }
48821 ++format;
48822 min_digits = atoi(argbuf);
48823 if(!min_digits)
48824 {
48825 Z_scripterrlog("Error formatting string: Invalid number '%s'\n", argbuf);
48826 }
48827 }
48828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19292 times.
19292 bool bin = (format[0] == 'b' || format[0] == 'B');
48829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19292 times.
19292 bool hex = (format[0] == 'x' || format[0] == 'X');
48830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19292 times.
19292 if(bin)
48831 {
48832 if(min_digits > 32)
48833 {
48834 Z_scripterrlog("Min digits argument cannot be larger than 32!"
48835 " Value will be truncated to 32.");
48836 min_digits = 32;
48837 }
48838 }
48839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19292 times.
19292 else if(min_digits > 10)
48840 {
48841 Z_scripterrlog("Min digits argument cannot be larger than 10!"
48842 " Value will be truncated to 10.");
48843 min_digits = 10;
48844 }
48845
48846 19292 bool tempbool = false;
48847
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18977 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 315 times.
19292 switch( format[0] )
48848 {
48849 case 'd':
48850 case 'f':
48851 case 'i': case 'p':
48852 case 'l':
48853 case 's':
48854 case 'c':
48855 case 'x': case 'X':
48856 case 'b': case 'B':
48857 {
48858 18977 ++next_arg;
48859
3/6
✓ Branch 0 taken 18977 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18977 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18977 times.
✗ Branch 5 not taken.
18977 oss << buf << zs_formatter(format,arg_val,min_digits,formatter_flags);
48860 18977 q = 300; //break main loop
48861 18977 break;
48862 }
48863 case 'a': //array print
48864 {
48865 ++next_arg;
48866 oss << buf << zs_formatter(format,arg_val,min_digits,formatter_flags);
48867 while(format[0] == 'a')
48868 {
48869 if(is_valid_format(format[1]))
48870 ++format;
48871 else break;
48872 }
48873 q = 300; //break main loop
48874 break;
48875 }
48876 case '%':
48877 {
48878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 if(min_digits)
48879 Z_scripterrlog("Cannot use minimum digits flag for '%%%%'\n");
48880 315 buf[q] = '%';
48881 315 break;
48882 }
48883 default:
48884 {
48885 if(is_old_args)
48886 buf[q] = format[0];
48887 else
48888 {
48889 Z_scripterrlog("Error: '%%%c' is not a valid printf argument.\n",format[0]);
48890 }
48891 break;
48892 }
48893 }
48894 19292 ++format;
48895 19292 }
48896 else
48897 {
48898 53666 buf[q] = format[0];
48899 53666 ++format;
48900 }
48901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72958 times.
72958 if(q == 255)
48902 {
48903 oss << buf;
48904 break;
48905 }
48906 72958 }
48907 }
48908
1/2
✓ Branch 0 taken 6856 times.
✗ Branch 1 not taken.
6856 return oss.str();
48909 10489 }
48910
48911 3606 void FFScript::do_printf(const bool v, const bool varg)
48912 {
48913 int32_t num_args, format_arrayptr;
48914
2/2
✓ Branch 0 taken 3319 times.
✓ Branch 1 taken 287 times.
3606 if(varg)
48915 {
48916 3319 num_args = zs_vargs.size();
48917 3319 format_arrayptr = SH::read_stack(ri->sp) / 10000;
48918 3319 }
48919 else
48920 {
48921 287 num_args = SH::get_arg(sarg1, v) / 10000;
48922 287 format_arrayptr = SH::read_stack(ri->sp + num_args) / 10000;
48923 }
48924 3606 ArrayManager fmt_am(format_arrayptr);
48925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3606 times.
3606 if(!fmt_am.invalid())
48926 {
48927 3606 string formatstr;
48928
1/2
✓ Branch 0 taken 3606 times.
✗ Branch 1 not taken.
3606 ArrayH::getString(format_arrayptr, formatstr, MAX_ZC_ARRAY_SIZE);
48929
48930
4/6
✓ Branch 0 taken 3319 times.
✓ Branch 1 taken 287 times.
✓ Branch 2 taken 3606 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3606 times.
3606 traceStr(zs_sprintf(formatstr.c_str(), num_args, varg ? zspr_varg_getter : zspr_stack_getter));
48931 3606 }
48932
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 3319 times.
3606 if(varg)
48933 3319 zs_vargs.clear();
48934 3606 }
48935 6883 void FFScript::do_sprintf(const bool v, const bool varg)
48936 {
48937 int32_t num_args, dest_arrayptr, format_arrayptr;
48938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6883 times.
6883 if(varg)
48939 {
48940 num_args = zs_vargs.size();
48941 dest_arrayptr = SH::read_stack(ri->sp + 1) / 10000;
48942 format_arrayptr = SH::read_stack(ri->sp) / 10000;
48943 }
48944 else
48945 {
48946 6883 num_args = SH::get_arg(sarg1, v) / 10000;
48947 6883 dest_arrayptr = SH::read_stack(ri->sp + num_args + 1) / 10000;
48948 6883 format_arrayptr = SH::read_stack(ri->sp + num_args) / 10000;
48949 }
48950 6883 ArrayManager fmt_am(format_arrayptr);
48951 6883 ArrayManager dst_am(dest_arrayptr);
48952
2/4
✓ Branch 0 taken 6883 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6883 times.
6883 if(fmt_am.invalid() || dst_am.invalid())
48953 ri->d[rEXP1] = 0;
48954 else
48955 {
48956 6883 string formatstr;
48957
1/2
✓ Branch 0 taken 6883 times.
✗ Branch 1 not taken.
6883 ArrayH::getString(format_arrayptr, formatstr, MAX_ZC_ARRAY_SIZE);
48958
48959
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6883 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6883 times.
6883 string output = zs_sprintf(formatstr.c_str(), num_args, varg ? zspr_varg_getter : zspr_stack_getter);
48960
2/4
✓ Branch 0 taken 6883 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6883 times.
6883 if(ArrayH::setArray(dest_arrayptr, output, true) == SH::_Overflow)
48961 {
48962 Z_scripterrlog("Dest string supplied to 'sprintf()' not large enough and cannot be resized\n");
48963 ri->d[rEXP1] = ArrayH::strlen(dest_arrayptr);
48964 }
48965 6883 else ri->d[rEXP1] = output.size();
48966 6883 }
48967
1/2
✓ Branch 0 taken 6883 times.
✗ Branch 1 not taken.
6883 if(varg)
48968 zs_vargs.clear();
48969 6883 }
48970 void FFScript::do_printfarr()
48971 {
48972 int32_t format_arrayptr = SH::read_stack(ri->sp + 1) / 10000,
48973 args_arrayptr = SH::read_stack(ri->sp + 0) / 10000;
48974 ArrayManager fmt_am(format_arrayptr);
48975 ArrayManager arg_am(args_arrayptr);
48976 if(!(fmt_am.invalid() || arg_am.invalid()))
48977 {
48978 auto num_args = arg_am.size();
48979 string formatstr;
48980 ArrayH::getString(format_arrayptr, formatstr, MAX_ZC_ARRAY_SIZE);
48981
48982 traceStr(zs_sprintf(formatstr.c_str(), num_args,
48983 [&](int32_t,int32_t next_arg)
48984 {
48985 return arg_am.get(next_arg);
48986 }));
48987 }
48988 }
48989 void FFScript::do_sprintfarr()
48990 {
48991 int32_t dest_arrayptr = SH::read_stack(ri->sp + 2) / 10000,
48992 format_arrayptr = SH::read_stack(ri->sp + 1) / 10000,
48993 args_arrayptr = SH::read_stack(ri->sp + 0) / 10000;
48994 ArrayManager fmt_am(format_arrayptr);
48995 ArrayManager arg_am(args_arrayptr);
48996 ArrayManager dst_am(dest_arrayptr);
48997 if(fmt_am.invalid() || arg_am.invalid() || dst_am.invalid())
48998 ri->d[rEXP1] = 0;
48999 else
49000 {
49001 auto num_args = arg_am.size();
49002 string formatstr;
49003 ArrayH::getString(format_arrayptr, formatstr, MAX_ZC_ARRAY_SIZE);
49004
49005 string output = zs_sprintf(formatstr.c_str(), num_args,
49006 [&](int32_t,int32_t next_arg)
49007 {
49008 return arg_am.get(next_arg);
49009 });
49010
49011 if(ArrayH::setArray(dest_arrayptr, output, true) == SH::_Overflow)
49012 {
49013 Z_scripterrlog("Dest string supplied to 'sprintfa()' not large enough and cannot be resized\n");
49014 ri->d[rEXP1] = ArrayH::strlen(dest_arrayptr);
49015 }
49016 else ri->d[rEXP1] = output.size();
49017 }
49018 }
49019 27143 void FFScript::do_varg_max()
49020 {
49021 27143 int32_t num_args = zs_vargs.size();
49022 27143 int32_t val = 0;
49023
1/2
✓ Branch 0 taken 27143 times.
✗ Branch 1 not taken.
27143 if (num_args > 0)
49024 27143 val = zs_vargs.at(0);
49025
2/2
✓ Branch 0 taken 27143 times.
✓ Branch 1 taken 27143 times.
54286 for(auto q = 1; q < num_args; ++q)
49026 {
49027 27143 int32_t tval = zs_vargs.at(q);
49028
2/2
✓ Branch 0 taken 9172 times.
✓ Branch 1 taken 17971 times.
27143 if(tval > val) val = tval;
49029 27143 }
49030 27143 zs_vargs.clear();
49031 27143 ri->d[rEXP1] = val;
49032 27143 }
49033 72 void FFScript::do_varg_min()
49034 {
49035 72 int32_t num_args = zs_vargs.size();
49036 72 int32_t val = 0;
49037
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if (num_args > 0)
49038 72 val = zs_vargs.at(0);
49039
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 72 times.
144 for(auto q = 1; q < num_args; ++q)
49040 {
49041 72 int32_t tval = zs_vargs.at(q);
49042
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(tval < val) val = tval;
49043 72 }
49044 72 zs_vargs.clear();
49045 72 ri->d[rEXP1] = val;
49046 72 }
49047 void FFScript::do_varg_choose()
49048 {
49049 int32_t num_args = zs_vargs.size();
49050 int32_t val = 0;
49051 if(num_args > 0)
49052 {
49053 int32_t choice = zc_rand(num_args-1);
49054 val = zs_vargs.at(choice);
49055 }
49056 zs_vargs.clear();
49057 ri->d[rEXP1] = val;
49058 }
49059 void FFScript::do_varg_makearray(ScriptType type, const uint32_t UID)
49060 {
49061 size_t num_args = zs_vargs.size();
49062 //
49063 dword ptrval;
49064 for(ptrval = 1; localRAM[ptrval].Valid(); ptrval++) ;
49065
49066 if(ptrval >= NUM_ZSCRIPT_ARRAYS)
49067 {
49068 Z_scripterrlog("%d local arrays already in use, no more can be allocated\n", NUM_ZSCRIPT_ARRAYS-1);
49069 ptrval = 0;
49070 }
49071 else
49072 {
49073 ZScriptArray &a = localRAM[ptrval]; //marginally faster for large arrays if we use a reference
49074
49075 a.Resize(num_args);
49076 a.setValid(true);
49077
49078 for(size_t j = 0; j < num_args; ++j)
49079 a[j] = zs_vargs[j]; //initialize array
49080
49081 arrayOwner[ptrval].reown(type, UID);
49082 }
49083 //
49084 zs_vargs.clear();
49085 ri->d[rEXP1] = ptrval*10000;
49086 }
49087
49088 void FFScript::do_breakpoint()
49089 {
49090 int32_t arrayptr = get_register(sarg1) / 10000;
49091 string str;
49092 if(arrayptr && sarg1 != NUL)
49093 {
49094 ArrayH::getString(arrayptr, str, 512);
49095 str = "Breakpoint: " + str + "\n";
49096 }
49097 else str = "Breakpoint\n";
49098 TraceScriptIDs();
49099 al_trace("%s", str.c_str());
49100
49101 if ( zscript_debugger )
49102 {
49103 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
49104 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str.c_str());
49105 }
49106 if( zasm_debugger )
49107 {
49108 FFCore.zasm_break_mode = ZASM_BREAK_HALT; //Halt ZASM debugger; break execution
49109 coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
49110 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str.c_str());
49111 }
49112 }
49113
49114 void FFScript::do_tracenl()
49115 {
49116 safe_al_trace("\n");
49117
49118 if ( zscript_debugger )
49119 {
49120 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
49121 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),"\n");
49122 }
49123 }
49124
49125
49126 36945 void FFScript::TraceScriptIDs(bool zasm_console)
49127 {
49128 if(DEVTIMESTAMP)
49129 {
49130 if(!zasm_debugger && zasm_console) return;
49131 CConsoleLoggerEx console = (zasm_console ? coloured_console : zscript_coloured_console);
49132 bool cond = (zasm_console ? zasm_debugger : zscript_debugger);
49133
49134 char buf[256] = {0};
49135 //Calculate timestamp
49136 struct tm * tm_struct;
49137 time_t sysRTC;
49138 time (&sysRTC);
49139 tm_struct = localtime (&sysRTC);
49140
49141 sprintf(buf, "[%d:%d:%d] ", tm_struct->tm_hour, tm_struct->tm_min, tm_struct->tm_sec);
49142 //
49143
49144 al_trace("%s", buf);
49145 if ( cond ) {console.safeprint((CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
49146 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),buf); }
49147 }
49148
2/2
✓ Branch 0 taken 33593 times.
✓ Branch 1 taken 3352 times.
36945 if(get_qr(qr_TRACESCRIPTIDS) || DEVLOGGING )
49149 {
49150
2/4
✓ Branch 0 taken 3352 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3352 times.
✗ Branch 3 not taken.
3352 if(!zasm_debugger && zasm_console) return;
49151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3352 times.
3352 CConsoleLoggerEx console = (zasm_console ? coloured_console : zscript_coloured_console);
49152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3352 times.
3352 bool cond = (zasm_console ? zasm_debugger : zscript_debugger);
49153 3352 char buf[256] = {0};
49154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3352 times.
3352 if(script_funcrun)
49155 {
49156 sprintf(buf, "Destructor(%d,%s): ", ri->thiskey, destructstr?destructstr->c_str():"UNKNOWN");
49157 }
49158
2/18
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1294 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 2058 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
3352 else switch(curScriptType)
49159 {
49160 case ScriptType::Global:
49161 {
49162 switch(curScriptNum)
49163 {
49164 case GLOBAL_SCRIPT_INIT:
49165 sprintf(buf, "Global Init(%s): ", globalmap[curScriptNum].scriptname.c_str());
49166 break;
49167 case GLOBAL_SCRIPT_GAME:
49168 sprintf(buf, "Global Active(%s): ", globalmap[curScriptNum].scriptname.c_str());
49169 break;
49170 case GLOBAL_SCRIPT_END:
49171 sprintf(buf, "Global Exit(%s): ", globalmap[curScriptNum].scriptname.c_str());
49172 break;
49173 case GLOBAL_SCRIPT_ONSAVELOAD:
49174 sprintf(buf, "Global SaveLoad(%s): ", globalmap[curScriptNum].scriptname.c_str());
49175 break;
49176 case GLOBAL_SCRIPT_ONLAUNCH:
49177 sprintf(buf, "Global Launch(%s): ", globalmap[curScriptNum].scriptname.c_str());
49178 break;
49179 case GLOBAL_SCRIPT_ONCONTGAME:
49180 sprintf(buf, "Global ContGame(%s): ", globalmap[curScriptNum].scriptname.c_str());
49181 break;
49182 case GLOBAL_SCRIPT_F6:
49183 sprintf(buf, "Global F6Menu(%s): ", globalmap[curScriptNum].scriptname.c_str());
49184 break;
49185 case GLOBAL_SCRIPT_ONSAVE:
49186 sprintf(buf, "Global Save(%s): ", globalmap[curScriptNum].scriptname.c_str());
49187 break;
49188 }
49189 break;
49190 }
49191
49192 case ScriptType::Player:
49193 {
49194 switch(curScriptNum)
49195 {
49196 case SCRIPT_PLAYER_INIT:
49197 sprintf(buf, "Player Init(%s): ", playermap[curScriptNum-1].scriptname.c_str());
49198 break;
49199 case SCRIPT_PLAYER_ACTIVE:
49200 sprintf(buf, "Player Active(%s): ", playermap[curScriptNum-1].scriptname.c_str());
49201 break;
49202 case SCRIPT_PLAYER_DEATH:
49203 sprintf(buf, "Player Death(%s): ", playermap[curScriptNum-1].scriptname.c_str());
49204 break;
49205 case SCRIPT_PLAYER_WIN:
49206 sprintf(buf, "Player Win(%s): ", playermap[curScriptNum-1].scriptname.c_str());
49207 break;
49208 }
49209 break;
49210 }
49211
49212 case ScriptType::Lwpn:
49213 sprintf(buf, "LWeapon(%u, %s): ", curScriptNum,lwpnmap[curScriptNum-1].scriptname.c_str());
49214 break;
49215
49216 case ScriptType::Ewpn:
49217 sprintf(buf, "EWeapon(%u, %s): ", curScriptNum,ewpnmap[curScriptNum-1].scriptname.c_str());
49218 break;
49219
49220 case ScriptType::NPC:
49221 sprintf(buf, "NPC(%u, %s): ", curScriptNum,npcmap[curScriptNum-1].scriptname.c_str());
49222 break;
49223
49224 case ScriptType::FFC:
49225
1/2
✓ Branch 0 taken 1294 times.
✗ Branch 1 not taken.
1294 sprintf(buf, "FFC(%u, %s): ", curScriptNum,ffcmap[curScriptNum-1].scriptname.c_str());
49226 1294 break;
49227
49228 case ScriptType::Item:
49229 sprintf(buf, "Item(%u, %s): ", curScriptNum,itemmap[curScriptNum-1].scriptname.c_str());
49230 break;
49231
49232 case ScriptType::OnMap:
49233 sprintf(buf, "DMapMap(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
49234 break;
49235 case ScriptType::ScriptedActiveSubscreen:
49236 sprintf(buf, "DMapASub(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
49237 break;
49238 case ScriptType::ScriptedPassiveSubscreen:
49239 sprintf(buf, "DMapPSub(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
49240 break;
49241 case ScriptType::DMap:
49242
1/2
✓ Branch 0 taken 2058 times.
✗ Branch 1 not taken.
2058 sprintf(buf, "DMap(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
49243 2058 break;
49244
49245 case ScriptType::ItemSprite:
49246 sprintf(buf, "ItemSprite(%u, %s): ", curScriptNum,itemspritemap[curScriptNum-1].scriptname.c_str());
49247 break;
49248
49249 case ScriptType::Screen:
49250 sprintf(buf, "Screen(%u, %s): ", curScriptNum,screenmap[curScriptNum-1].scriptname.c_str());
49251 break;
49252
49253 case ScriptType::Combo:
49254 sprintf(buf, "Combo(%u, %s): ", curScriptNum,comboscriptmap[curScriptNum-1].scriptname.c_str());
49255 break;
49256
49257 case ScriptType::Generic:
49258 sprintf(buf, "Generic(%u, %s): ", curScriptNum,genericmap[curScriptNum-1].scriptname.c_str());
49259 break;
49260
49261 case ScriptType::GenericFrozen:
49262 sprintf(buf, "GenericFRZ(%u, %s): ", curScriptNum,genericmap[curScriptNum-1].scriptname.c_str());
49263 break;
49264
49265 case ScriptType::EngineSubscreen:
49266 sprintf(buf, "Subscreen(%u, %s): ", curScriptNum,subscreenmap[curScriptNum-1].scriptname.c_str());
49267 break;
49268 }
49269
49270
1/2
✓ Branch 0 taken 3352 times.
✗ Branch 1 not taken.
3352 al_trace("%s", buf);
49271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3352 times.
3352 if ( cond )
49272 console.safeprint((CConsoleLoggerEx::COLOR_GREEN|CConsoleLoggerEx::COLOR_INTENSITY|
49273 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),buf);
49274 3352 }
49275 36945 }
49276
49277 2 void FFScript::do_cleartrace()
49278 {
49279 2 zc_trace_clear();
49280 2 clearConsole();
49281 2 }
49282
49283 1 string inttobase(word base, int32_t x, word mindigits)
49284 {
49285 static const char coeff[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
49286
49287 1 string s2;
49288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 word digits = zc_max(mindigits - 1, word(floor(log(double(x)) / log(double(base)))));
49289
49290
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for(int32_t i = digits; i >= 0; i--)
49291 {
49292
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 s2 += coeff[word(floor(x / pow(double(base), i))) % base];
49293 1 }
49294
49295 1 return s2;
49296
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 }
49297
49298 1 void FFScript::do_tracetobase()
49299 {
49300 1 int32_t x = SH::read_stack(ri->sp + 2) / 10000;
49301 1 uint32_t base = vbound(SH::read_stack(ri->sp + 1) / 10000, 2, 36);
49302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 uint32_t mindigits = zc_max(1, SH::read_stack(ri->sp) / 10000);
49303
49304
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 string s2 = x < 0 ? "-": "";
49305
49306
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 switch(base)
49307 {
49308 case 8:
49309 s2 += '0';
49310 break;
49311
49312 case 16:
49313 s2 += "0x";
49314 break;
49315 }
49316
49317
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 s2 += inttobase(base, int32_t(fabs(double(x))), mindigits);
49318
49319
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 switch(base)
49320 {
49321 case 8:
49322 case 10:
49323 case 16:
49324 1 break;
49325
49326 case 2:
49327 s2 += 'b';
49328 break;
49329
49330 default:
49331 std::stringstream ss;
49332 ss << " (Base " << base << ')';
49333 s2 += ss.str();
49334 break;
49335 }
49336
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 TraceScriptIDs();
49337
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 s2 += "\n";
49338
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 al_trace("%s", s2.c_str());
49339
49340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( zscript_debugger )
49341 {
49342 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
49343 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),s2.c_str());
49344 }
49345 1 }
49346
49347 //SRAM Functions
49348 void FFScript::write_dmaps(PACKFILE *f, int32_t vers_id)
49349 {
49350 word dmap_count=count_dmaps();
49351
49352 dmap_count=zc_min(dmap_count, 512);
49353 dmap_count=zc_min(dmap_count, MAXDMAPS-0);
49354
49355 //finally... section data
49356 if(!p_iputw(dmap_count,f))
49357 {
49358 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",5);
49359 }
49360
49361
49362 for(int32_t i=0; i<dmap_count; i++)
49363 {
49364 if(!p_putc(DMaps[i].map,f))
49365 {
49366 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",6);
49367 }
49368
49369 if(!p_iputw(DMaps[i].level,f))
49370 {
49371 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",7);
49372 }
49373
49374 if(!p_putc(DMaps[i].xoff,f))
49375 {
49376 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",8);
49377 }
49378
49379 if(!p_putc(DMaps[i].compass,f))
49380 {
49381 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",9);
49382 }
49383
49384 if(!p_iputw(DMaps[i].color,f))
49385 {
49386 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",10);
49387 }
49388
49389 if(!p_putc(DMaps[i].midi,f))
49390 {
49391 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",11);
49392 }
49393
49394 if(!p_putc(DMaps[i].cont,f))
49395 {
49396 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",12);
49397 }
49398
49399 if(!p_putc(DMaps[i].type,f))
49400 {
49401 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",13);
49402 }
49403
49404 for(int32_t j=0; j<8; j++)
49405 {
49406 if(!p_putc(DMaps[i].grid[j],f))
49407 {
49408 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",14);
49409 }
49410 }
49411
49412 //16
49413 if(!pfwrite(&DMaps[i].name,sizeof(DMaps[0].name),f))
49414 {
49415 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",15);
49416 }
49417
49418 if(!pfwrite(&DMaps[i].title,sizeof(DMaps[0].title),f))
49419 {
49420 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",16);
49421 }
49422
49423 if(!pfwrite(&DMaps[i].intro,sizeof(DMaps[0].intro),f))
49424 {
49425 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",17);
49426 }
49427
49428 if(!p_iputl(DMaps[i].minimap_1_tile,f))
49429 {
49430 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",18);
49431 }
49432
49433 if(!p_putc(DMaps[i].minimap_1_cset,f))
49434 {
49435 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",19);
49436 }
49437
49438 if(!p_iputl(DMaps[i].minimap_2_tile,f))
49439 {
49440 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",20);
49441 }
49442
49443 if(!p_putc(DMaps[i].minimap_2_cset,f))
49444 {
49445 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",21);
49446 }
49447
49448 if(!p_iputl(DMaps[i].largemap_1_tile,f))
49449 {
49450 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",22);
49451 }
49452
49453 if(!p_putc(DMaps[i].largemap_1_cset,f))
49454 {
49455 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",23);
49456 }
49457
49458 if(!p_iputl(DMaps[i].largemap_2_tile,f))
49459 {
49460 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",24);
49461 }
49462
49463 if(!p_putc(DMaps[i].largemap_2_cset,f))
49464 {
49465 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
49466 }
49467
49468 if(!pfwrite(&DMaps[i].tmusic,sizeof(DMaps[0].tmusic),f))
49469 {
49470 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
49471 }
49472
49473 if(!p_putc(DMaps[i].tmusictrack,f))
49474 {
49475 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
49476 }
49477
49478 if(!p_putc(DMaps[i].active_subscreen,f))
49479 {
49480 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
49481 }
49482
49483 if(!p_putc(DMaps[i].passive_subscreen,f))
49484 {
49485 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",27);
49486 }
49487
49488 byte disabled[32];
49489 memset(disabled,0,32);
49490
49491 for(int32_t j=0; j<MAXITEMS; j++)
49492 {
49493 if(DMaps[i].disableditems[j])
49494 {
49495 disabled[j/8] |= (1 << (j%8));
49496 }
49497 }
49498
49499 if(!pfwrite(disabled,32,f))
49500 {
49501 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",28);
49502 }
49503
49504 if(!p_iputl(DMaps[i].flags,f))
49505 {
49506 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",29);
49507 }
49508 if(!p_putc(DMaps[i].sideview,f))
49509 {
49510 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",30);
49511 }
49512 if(!p_iputw(DMaps[i].script,f))
49513 {
49514 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",31);
49515 }
49516 for ( int32_t q = 0; q < 8; q++ )
49517 {
49518 if(!p_iputl(DMaps[i].initD[q],f))
49519 {
49520 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",32);
49521 }
49522
49523 }
49524 for ( int32_t q = 0; q < 8; q++ )
49525 {
49526 for ( int32_t w = 0; w < 65; w++ )
49527 {
49528 if (!p_putc(DMaps[i].initD_label[q][w],f))
49529 {
49530 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",33);
49531 }
49532 }
49533 }
49534 }
49535 }
49536 void FFScript::read_dmaps(PACKFILE *f, int32_t vers_id)
49537 {
49538 word dmap_count=count_dmaps();
49539
49540 dmap_count=zc_min(dmap_count, 512);
49541 dmap_count=zc_min(dmap_count, MAXDMAPS-0);
49542
49543 //finally... section data
49544 if(!p_igetw(&dmap_count,f))
49545 {
49546 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",5);
49547 }
49548
49549
49550 for(int32_t i=0; i<dmap_count; i++)
49551 {
49552 if(!p_getc(&DMaps[i].map,f))
49553 {
49554 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",6);
49555 }
49556
49557 if(!p_igetw(&DMaps[i].level,f))
49558 {
49559 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",7);
49560 }
49561
49562 if(!p_getc(&DMaps[i].xoff,f))
49563 {
49564 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",8);
49565 }
49566
49567 if(!p_getc(&DMaps[i].compass,f))
49568 {
49569 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",9);
49570 }
49571
49572 if(!p_igetw(&DMaps[i].color,f))
49573 {
49574 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",10);
49575 }
49576
49577 if(!p_getc(&DMaps[i].midi,f))
49578 {
49579 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",11);
49580 }
49581
49582 if(!p_getc(&DMaps[i].cont,f))
49583 {
49584 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",12);
49585 }
49586
49587 if(!p_getc(&DMaps[i].type,f))
49588 {
49589 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",13);
49590 }
49591
49592 for(int32_t j=0; j<8; j++)
49593 {
49594 if(!p_getc(&DMaps[i].grid[j],f))
49595 {
49596 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",14);
49597 }
49598 }
49599
49600 //16
49601 if(!pfread((&DMaps[i].name),sizeof(DMaps[0].name),f))
49602 {
49603 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",15);
49604 }
49605
49606 if(!pfread((&DMaps[i].title),sizeof(DMaps[0].title),f))
49607 {
49608 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",16);
49609 }
49610
49611 if(!pfread((&DMaps[i].intro),sizeof(DMaps[0].intro),f))
49612 {
49613 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",17);
49614 }
49615
49616 if(!p_igetl(&DMaps[i].minimap_1_tile,f))
49617 {
49618 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",18);
49619 }
49620
49621 if(!p_getc(&DMaps[i].minimap_1_cset,f))
49622 {
49623 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",19);
49624 }
49625
49626 if(!p_igetl(&DMaps[i].minimap_2_tile,f))
49627 {
49628 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",20);
49629 }
49630
49631 if(!p_getc(&DMaps[i].minimap_2_cset,f))
49632 {
49633 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",21);
49634 }
49635
49636 if(!p_igetl(&DMaps[i].largemap_1_tile,f))
49637 {
49638 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",22);
49639 }
49640
49641 if(!p_getc(&DMaps[i].largemap_1_cset,f))
49642 {
49643 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",23);
49644 }
49645
49646 if(!p_igetl(&DMaps[i].largemap_2_tile,f))
49647 {
49648 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",24);
49649 }
49650
49651 if(!p_getc(&DMaps[i].largemap_2_cset,f))
49652 {
49653 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
49654 }
49655
49656 if(!pfread((&DMaps[i].tmusic),sizeof(DMaps[0].tmusic),f))
49657 {
49658 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
49659 }
49660
49661 if(!p_getc(&DMaps[i].tmusictrack,f))
49662 {
49663 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
49664 }
49665
49666 if(!p_getc(&DMaps[i].active_subscreen,f))
49667 {
49668 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
49669 }
49670
49671 if(!p_getc(&DMaps[i].passive_subscreen,f))
49672 {
49673 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",27);
49674 }
49675
49676 byte disabled[32];
49677 memset(disabled,0,32);
49678
49679 for(int32_t j=0; j<MAXITEMS; j++)
49680 {
49681 if(&DMaps[i].disableditems[j])
49682 {
49683 disabled[j/8] |= (1 << (j%8));
49684 }
49685 }
49686
49687 if(!pfread(disabled,32,f))
49688 {
49689 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",28);
49690 }
49691
49692 if(!p_igetl(&DMaps[i].flags,f))
49693 {
49694 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",29);
49695 }
49696 if(!p_getc(&DMaps[i].sideview,f))
49697 {
49698 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",30);
49699 }
49700 if(!p_igetw(&DMaps[i].script,f))
49701 {
49702 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",31);
49703 }
49704 for ( int32_t q = 0; q < 8; q++ )
49705 {
49706 if(!p_igetl(&DMaps[i].initD[q],f))
49707 {
49708 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",32);
49709 }
49710
49711 }
49712 for ( int32_t q = 0; q < 8; q++ )
49713 {
49714 for ( int32_t w = 0; w < 65; w++ )
49715 {
49716 if (!p_getc(&DMaps[i].initD_label[q][w],f))
49717 {
49718 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",33);
49719 }
49720 }
49721 }
49722 }
49723 }
49724
49725
49726
49727 void FFScript::read_combos(PACKFILE *f, int32_t version_id)
49728 {
49729
49730 word combos_used = 0;
49731
49732 if(!p_igetw(&combos_used,f))
49733 {
49734 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",5);
49735 }
49736
49737 for(int32_t i=0; i<combos_used; i++)
49738 {
49739 if(!p_igetl(&combobuf[i].tile,f))
49740 {
49741 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",6);
49742 }
49743
49744 if(!p_getc(&combobuf[i].flip,f))
49745 {
49746 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",7);
49747 }
49748
49749 if(!p_getc(&combobuf[i].walk,f))
49750 {
49751 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",8);
49752 }
49753
49754 if(!p_getc(&combobuf[i].type,f))
49755 {
49756 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",9);
49757 }
49758
49759 if(!p_getc(&combobuf[i].csets,f))
49760 {
49761 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",10);
49762 }
49763
49764 if(!p_getc(&combobuf[i].frames,f))
49765 {
49766 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",11);
49767 }
49768
49769 if(!p_getc(&combobuf[i].speed,f))
49770 {
49771 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",12);
49772 }
49773
49774 if(!p_igetw(&combobuf[i].nextcombo,f))
49775 {
49776 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",13);
49777 }
49778
49779 if(!p_getc(&combobuf[i].nextcset,f))
49780 {
49781 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",14);
49782 }
49783
49784 if(!p_getc(&combobuf[i].flag,f))
49785 {
49786 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",15);
49787 }
49788
49789 if(!p_getc(&combobuf[i].skipanim,f))
49790 {
49791 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",16);
49792 }
49793
49794 if(!p_igetw(&combobuf[i].nexttimer,f))
49795 {
49796 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",17);
49797 }
49798
49799 if(!p_getc(&combobuf[i].skipanimy,f))
49800 {
49801 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",18);
49802 }
49803
49804 if(!p_getc(&combobuf[i].animflags,f))
49805 {
49806 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",19);
49807 }
49808
49809 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
49810 {
49811 if(!p_igetl(&combobuf[i].attributes[q],f))
49812 {
49813 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",20);
49814 }
49815 }
49816 if(!p_igetl(&combobuf[i].usrflags,f))
49817 {
49818 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",21);
49819 }
49820 for ( int32_t q = 0; q < 6; q++ )
49821 {
49822 if(!p_igetl(&combobuf[i].triggerflags[q],f))
49823 {
49824 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",22);
49825 }
49826 }
49827
49828 if(!p_igetl(&combobuf[i].triggerlevel,f))
49829 {
49830 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",23);
49831 }
49832 for ( int32_t q = 0; q < 11; q++ )
49833 {
49834 if(!p_getc(&combobuf[i].label[q],f))
49835 {
49836 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",24);
49837 }
49838 }
49839 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
49840 {
49841 if(!p_getc(&combobuf[i].attribytes[q],f))
49842 {
49843 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",25);
49844 }
49845 }
49846 if(!p_igetw(&combobuf[i].script,f))
49847 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",26);
49848 for ( int32_t q = 0; q < 2; q++ )
49849 {
49850 if(!p_igetl(&combobuf[i].initd[q],f))
49851 {
49852 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",27);
49853 }
49854 }
49855 if(!p_igetl(&combobuf[i].o_tile,f))
49856 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",28);
49857 if(!p_getc(&combobuf[i].cur_frame,f))
49858 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",29);
49859 if(!p_getc(&combobuf[i].aclk,f))
49860 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",30);
49861 }
49862 }
49863
49864 void FFScript::write_combos(PACKFILE *f, int32_t version_id)
49865 {
49866
49867 word combos_used = 0;
49868
49869 //finally... section data
49870 combos_used=count_combos()-0;
49871 combos_used=zc_min(combos_used, MAXCOMBOS);
49872
49873 if(!p_iputw(combos_used,f))
49874 {
49875 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",5);
49876 }
49877
49878 for(int32_t i=0; i<combos_used; i++)
49879 {
49880 if(!p_iputl(combobuf[i].tile,f))
49881 {
49882 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",6);
49883 }
49884
49885 if(!p_putc(combobuf[i].flip,f))
49886 {
49887 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",7);
49888 }
49889
49890 if(!p_putc(combobuf[i].walk,f))
49891 {
49892 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",8);
49893 }
49894
49895 if(!p_putc(combobuf[i].type,f))
49896 {
49897 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",9);
49898 }
49899
49900 if(!p_putc(combobuf[i].csets,f))
49901 {
49902 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",10);
49903 }
49904
49905 if(!p_putc(combobuf[i].frames,f))
49906 {
49907 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",11);
49908 }
49909
49910 if(!p_putc(combobuf[i].speed,f))
49911 {
49912 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",12);
49913 }
49914
49915 if(!p_iputw(combobuf[i].nextcombo,f))
49916 {
49917 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",13);
49918 }
49919
49920 if(!p_putc(combobuf[i].nextcset,f))
49921 {
49922 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",14);
49923 }
49924
49925 if(!p_putc(combobuf[i].flag,f))
49926 {
49927 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",15);
49928 }
49929
49930 if(!p_putc(combobuf[i].skipanim,f))
49931 {
49932 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",16);
49933 }
49934
49935 if(!p_iputw(combobuf[i].nexttimer,f))
49936 {
49937 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",17);
49938 }
49939
49940 if(!p_putc(combobuf[i].skipanimy,f))
49941 {
49942 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",18);
49943 }
49944
49945 if(!p_putc(combobuf[i].animflags,f))
49946 {
49947 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",19);
49948 }
49949
49950 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
49951 {
49952 if(!p_iputl(combobuf[i].attributes[q],f))
49953 {
49954 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",20);
49955 }
49956 }
49957 if(!p_iputl(combobuf[i].usrflags,f))
49958 {
49959 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",21);
49960 }
49961 for ( int32_t q = 0; q < 6; q++ )
49962 {
49963 if(!p_iputl(combobuf[i].triggerflags[q],f))
49964 {
49965 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",22);
49966 }
49967 }
49968
49969 if(!p_iputl(combobuf[i].triggerlevel,f))
49970 {
49971 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",23);
49972 }
49973 for ( int32_t q = 0; q < 11; q++ )
49974 {
49975 if(!p_putc(combobuf[i].label[q],f))
49976 {
49977 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",24);
49978 }
49979 }
49980 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
49981 {
49982 if(!p_putc(combobuf[i].attribytes[q],f))
49983 {
49984 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",25);
49985 }
49986 }
49987 if(!p_iputw(combobuf[i].script,f))
49988 {
49989 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",26);
49990 }
49991 for ( int32_t q = 0; q < 2; q++ )
49992 {
49993 if(!p_iputl(combobuf[i].initd[q],f))
49994 {
49995 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",27);
49996 }
49997 }
49998 if(!p_iputl(combobuf[i].o_tile,f))
49999 {
50000 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",28);
50001 }
50002 if(!p_putc(combobuf[i].cur_frame,f))
50003 {
50004 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",29);
50005 }
50006 if(!p_putc(combobuf[i].aclk,f))
50007 {
50008 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",30);
50009 }
50010
50011 }
50012 }
50013 void FFScript::read_weaponsprtites(PACKFILE *f, int32_t vers_id)
50014 {
50015 for(int32_t i=0; i<MAXWPNS; i++)
50016 {
50017 word oldtile = 0;
50018 if(!p_igetw(&oldtile,f))
50019 {
50020 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",6);
50021 }
50022
50023 if(!p_getc(&wpnsbuf[i].misc,f))
50024 {
50025 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",7);
50026 }
50027
50028 if(!p_getc(&wpnsbuf[i].csets,f))
50029 {
50030 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",8);
50031 }
50032
50033 if(!p_getc(&wpnsbuf[i].frames,f))
50034 {
50035 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",9);
50036 }
50037
50038 if(!p_getc(&wpnsbuf[i].speed,f))
50039 {
50040 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",10);
50041 }
50042
50043 if(!p_getc(&wpnsbuf[i].type,f))
50044 {
50045 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",11);
50046 }
50047
50048 if(!p_igetw(&wpnsbuf[i].script,f))
50049 {
50050 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
50051 }
50052
50053 if(!p_igetl(&wpnsbuf[i].tile,f))
50054 {
50055 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
50056 }
50057 }
50058 }
50059 void FFScript::write_weaponsprtites(PACKFILE *f, int32_t vers_id)
50060 {
50061 for(int32_t i=0; i<MAXWPNS; i++)
50062 {
50063 if(!p_iputw(wpnsbuf[i].tile,f))
50064 {
50065 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",6);
50066 }
50067
50068 if(!p_putc(wpnsbuf[i].misc,f))
50069 {
50070 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",7);
50071 }
50072
50073 if(!p_putc(wpnsbuf[i].csets,f))
50074 {
50075 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",8);
50076 }
50077
50078 if(!p_putc(wpnsbuf[i].frames,f))
50079 {
50080 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",9);
50081 }
50082
50083 if(!p_putc(wpnsbuf[i].speed,f))
50084 {
50085 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",10);
50086 }
50087
50088 if(!p_putc(wpnsbuf[i].type,f))
50089 {
50090 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",11);
50091 }
50092
50093 if(!p_iputw(wpnsbuf[i].script,f))
50094 {
50095 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
50096 }
50097
50098 if(!p_iputl(wpnsbuf[i].tile,f))
50099 {
50100 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
50101 }
50102 }
50103 }
50104
50105
50106 void FFScript::read_enemies(PACKFILE *f, int32_t vers_id)
50107 {
50108 if ( !f ) return;
50109 for(int32_t i=0; i<MAXGUYS; i++)
50110 {
50111 if(!p_igetl(&guysbuf[i].flags,f))
50112 {
50113 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",6);
50114 }
50115
50116 if(!p_igetl(&guysbuf[i].flags2,f))
50117 {
50118 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",7);
50119 }
50120
50121 if(!p_igetl(&guysbuf[i].tile,f))
50122 {
50123 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",8);
50124 }
50125
50126 if(!p_getc(&guysbuf[i].width,f))
50127 {
50128 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",9);
50129 }
50130
50131 if(!p_getc(&guysbuf[i].height,f))
50132 {
50133 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",10);
50134 }
50135
50136 if(!p_igetl(&guysbuf[i].s_tile,f))
50137 {
50138 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",11);
50139 }
50140
50141 if(!p_getc(&guysbuf[i].s_width,f))
50142 {
50143 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",12);
50144 }
50145
50146 if(!p_getc(&guysbuf[i].s_height,f))
50147 {
50148 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",13);
50149 }
50150
50151 if(!p_igetl(&guysbuf[i].e_tile,f))
50152 {
50153 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",14);
50154 }
50155
50156 if(!p_getc(&guysbuf[i].e_width,f))
50157 {
50158 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",15);
50159 }
50160
50161 if(!p_getc(&guysbuf[i].e_height,f))
50162 {
50163 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",16);
50164 }
50165
50166 if(!p_igetw(&guysbuf[i].hp,f))
50167 {
50168 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",17);
50169 }
50170
50171 if(!p_igetw(&guysbuf[i].family,f))
50172 {
50173 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",18);
50174 }
50175
50176 if(!p_igetw(&guysbuf[i].cset,f))
50177 {
50178 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",19);
50179 }
50180
50181 if(!p_igetw(&guysbuf[i].anim,f))
50182 {
50183 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",20);
50184 }
50185
50186 if(!p_igetw(&guysbuf[i].e_anim,f))
50187 {
50188 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",21);
50189 }
50190
50191 if(!p_igetw(&guysbuf[i].frate,f))
50192 {
50193 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",22);
50194 }
50195
50196 if(!p_igetw(&guysbuf[i].e_frate,f))
50197 {
50198 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",23);
50199 }
50200
50201 if(!p_igetw(&guysbuf[i].dp,f))
50202 {
50203 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",24);
50204 }
50205
50206 if(!p_igetw(&guysbuf[i].wdp,f))
50207 {
50208 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",25);
50209 }
50210
50211 if(!p_igetw(&guysbuf[i].weapon,f))
50212 {
50213 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",26);
50214 }
50215
50216 if(!p_igetw(&guysbuf[i].rate,f))
50217 {
50218 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",27);
50219 }
50220
50221 if(!p_igetw(&guysbuf[i].hrate,f))
50222 {
50223 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",28);
50224 }
50225
50226 if(!p_igetw(&guysbuf[i].step,f))
50227 {
50228 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",29);
50229 }
50230
50231 if(!p_igetw(&guysbuf[i].homing,f))
50232 {
50233 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",30);
50234 }
50235
50236 if(!p_igetw(&guysbuf[i].grumble,f))
50237 {
50238 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",31);
50239 }
50240
50241 if(!p_igetw(&guysbuf[i].item_set,f))
50242 {
50243 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",32);
50244 }
50245
50246 if(!p_igetl(&guysbuf[i].misc1,f))
50247 {
50248 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",33);
50249 }
50250
50251 if(!p_igetl(&guysbuf[i].misc2,f))
50252 {
50253 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",34);
50254 }
50255
50256 if(!p_igetl(&guysbuf[i].misc3,f))
50257 {
50258 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",35);
50259 }
50260
50261 if(!p_igetl(&guysbuf[i].misc4,f))
50262 {
50263 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",36);
50264 }
50265
50266 if(!p_igetl(&guysbuf[i].misc5,f))
50267 {
50268 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",37);
50269 }
50270
50271 if(!p_igetl(&guysbuf[i].misc6,f))
50272 {
50273 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",38);
50274 }
50275
50276 if(!p_igetl(&guysbuf[i].misc7,f))
50277 {
50278 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",39);
50279 }
50280
50281 if(!p_igetl(&guysbuf[i].misc8,f))
50282 {
50283 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",40);
50284 }
50285
50286 if(!p_igetl(&guysbuf[i].misc9,f))
50287 {
50288 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",41);
50289 }
50290
50291 if(!p_igetl(&guysbuf[i].misc10,f))
50292 {
50293 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",42);
50294 }
50295
50296 if(!p_igetw(&guysbuf[i].bgsfx,f))
50297 {
50298 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",43);
50299 }
50300
50301 if(!p_igetw(&guysbuf[i].bosspal,f))
50302 {
50303 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",44);
50304 }
50305
50306 if(!p_igetw(&guysbuf[i].extend,f))
50307 {
50308 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",45);
50309 }
50310
50311 for(int32_t j=0; j < edefLAST; j++)
50312 {
50313 if(!p_getc(&guysbuf[i].defense[j],f))
50314 {
50315 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",46);
50316 }
50317 }
50318
50319 if(!p_getc(&guysbuf[i].hitsfx,f))
50320 {
50321 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",47);
50322 }
50323
50324 if(!p_getc(&guysbuf[i].deadsfx,f))
50325 {
50326 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",48);
50327 }
50328
50329 if(!p_igetl(&guysbuf[i].misc11,f))
50330 {
50331 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",49);
50332 }
50333
50334 if(!p_igetl(&guysbuf[i].misc12,f))
50335 {
50336 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",50);
50337 }
50338
50339 //New 2.6 defences
50340 for(int32_t j=edefLAST; j < edefLAST255; j++)
50341 {
50342 if(!p_getc(&guysbuf[i].defense[j],f))
50343 {
50344 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",51);
50345 }
50346 }
50347
50348 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
50349 if(!p_igetl(&guysbuf[i].txsz,f))
50350 {
50351 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",52);
50352 }
50353 if(!p_igetl(&guysbuf[i].tysz,f))
50354 {
50355 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",53);
50356 }
50357 if(!p_igetl(&guysbuf[i].hxsz,f))
50358 {
50359 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",54);
50360 }
50361 if(!p_igetl(&guysbuf[i].hysz,f))
50362 {
50363 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",55);
50364 }
50365 if(!p_igetl(&guysbuf[i].hzsz,f))
50366 {
50367 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",56);
50368 }
50369 // These are not fixed types, but ints, so they are safe to use here.
50370 if(!p_igetl(&guysbuf[i].hxofs,f))
50371 {
50372 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",57);
50373 }
50374 if(!p_igetl(&guysbuf[i].hyofs,f))
50375 {
50376 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",58);
50377 }
50378 if(!p_igetl(&guysbuf[i].xofs,f))
50379 {
50380 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",59);
50381 }
50382 if(!p_igetl(&guysbuf[i].yofs,f))
50383 {
50384 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",60);
50385 }
50386 if(!p_igetl(&guysbuf[i].zofs,f))
50387 {
50388 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",61);
50389 }
50390 if(!p_igetl(&guysbuf[i].wpnsprite,f))
50391 {
50392 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",62);
50393 }
50394 if(!p_igetl(&guysbuf[i].SIZEflags,f))
50395 {
50396 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",63);
50397 }
50398 if(!p_igetl(&guysbuf[i].frozentile,f))
50399 {
50400 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",64);
50401 }
50402 if(!p_igetl(&guysbuf[i].frozencset,f))
50403 {
50404 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",65);
50405 }
50406 if(!p_igetl(&guysbuf[i].frozenclock,f))
50407 {
50408 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",66);
50409 }
50410
50411 for ( int32_t q = 0; q < 10; q++ )
50412 {
50413 if(!p_igetw(&guysbuf[i].frozenmisc[q],f))
50414 {
50415 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",67);
50416 }
50417 }
50418 if(!p_igetw(&guysbuf[i].firesfx,f))
50419 {
50420 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",68);
50421 }
50422 //misc 16->31
50423 if(!p_igetl(&guysbuf[i].misc16,f))
50424 {
50425 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",69);
50426 }
50427 if(!p_igetl(&guysbuf[i].misc17,f))
50428 {
50429 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",70);
50430 }
50431 if(!p_igetl(&guysbuf[i].misc18,f))
50432 {
50433 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",71);
50434 }
50435 if(!p_igetl(&guysbuf[i].misc19,f))
50436 {
50437 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",72);
50438 }
50439 if(!p_igetl(&guysbuf[i].misc20,f))
50440 {
50441 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",73);
50442 }
50443 if(!p_igetl(&guysbuf[i].misc21,f))
50444 {
50445 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",74);
50446 }
50447 if(!p_igetl(&guysbuf[i].misc22,f))
50448 {
50449 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",75);
50450 }
50451 if(!p_igetl(&guysbuf[i].misc23,f))
50452 {
50453 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",76);
50454 }
50455 if(!p_igetl(&guysbuf[i].misc24,f))
50456 {
50457 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",77);
50458 }
50459 if(!p_igetl(&guysbuf[i].misc25,f))
50460 {
50461 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",78);
50462 }
50463 if(!p_igetl(&guysbuf[i].misc26,f))
50464 {
50465 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",79);
50466 }
50467 if(!p_igetl(&guysbuf[i].misc27,f))
50468 {
50469 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",80);
50470 }
50471 if(!p_igetl(&guysbuf[i].misc28,f))
50472 {
50473 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",81);
50474 }
50475 if(!p_igetl(&guysbuf[i].misc29,f))
50476 {
50477 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",82);
50478 }
50479 if(!p_igetl(&guysbuf[i].misc30,f))
50480 {
50481 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",83);
50482 }
50483 if(!p_igetl(&guysbuf[i].misc31,f))
50484 {
50485 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",84);
50486 }
50487 if(!p_igetl(&guysbuf[i].misc32,f))
50488 {
50489 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",85);
50490 }
50491 for ( int32_t q = 0; q < 32; q++ )
50492 {
50493 if(!p_igetl(&guysbuf[i].movement[q],f))
50494 {
50495 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",86);
50496 }
50497 }
50498 for ( int32_t q = 0; q < 32; q++ )
50499 {
50500 if(!p_igetl(&guysbuf[i].new_weapon[q],f))
50501 {
50502 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",87);
50503 }
50504 }
50505 if(!p_igetw(&guysbuf[i].script,f))
50506 {
50507 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",88);
50508 }
50509 for ( int32_t q = 0; q < 8; q++ )
50510 {
50511 if(!p_igetl(&guysbuf[i].initD[q],f))
50512 {
50513 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",89);
50514 }
50515 }
50516 for ( int32_t q = 0; q < 2; q++ )
50517 {
50518 if(!p_igetl(&guysbuf[i].initA[q],f))
50519 {
50520 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",90);
50521 }
50522 }
50523 if(!p_igetl(&guysbuf[i].editorflags,f))
50524 {
50525 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",91);
50526 }
50527 //somehow forgot these in the older builds -Z
50528 if(!p_igetl(&guysbuf[i].misc13,f))
50529 {
50530 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",92);
50531 }
50532 if(!p_igetl(&guysbuf[i].misc14,f))
50533 {
50534 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",93);
50535 }
50536 if(!p_igetl(&guysbuf[i].misc15,f))
50537 {
50538 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",94);
50539 }
50540
50541 //Enemy Editor InitD[] labels
50542 for ( int32_t q = 0; q < 8; q++ )
50543 {
50544 for ( int32_t w = 0; w < 65; w++ )
50545 {
50546 if(!p_getc(&guysbuf[i].initD_label[q][w],f))
50547 {
50548 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",95);
50549 }
50550 }
50551 for ( int32_t w = 0; w < 65; w++ )
50552 {
50553 if(!p_getc(&guysbuf[i].weapon_initD_label[q][w],f))
50554 {
50555 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",96);
50556 }
50557 }
50558 }
50559 if(!p_igetw(&guysbuf[i].weaponscript,f))
50560 {
50561 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",97);
50562 }
50563 //eweapon initD
50564 for ( int32_t q = 0; q < 8; q++ )
50565 {
50566 if(!p_igetl(&guysbuf[i].weap_initiald[q],f))
50567 {
50568 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",98);
50569 }
50570 }
50571
50572 }
50573 }
50574
50575 void FFScript::write_enemies(PACKFILE *f, int32_t vers_id)
50576 {
50577 if ( !f ) return;
50578 for(int32_t i=0; i<MAXGUYS; i++)
50579 {
50580 if(!p_iputl(guysbuf[i].flags,f))
50581 {
50582 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",6);
50583 }
50584
50585 if(!p_iputl(guysbuf[i].flags2,f))
50586 {
50587 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",7);
50588 }
50589
50590 if(!p_iputl(guysbuf[i].tile,f))
50591 {
50592 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",8);
50593 }
50594
50595 if(!p_putc(guysbuf[i].width,f))
50596 {
50597 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",9);
50598 }
50599
50600 if(!p_putc(guysbuf[i].height,f))
50601 {
50602 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",10);
50603 }
50604
50605 if(!p_iputl(guysbuf[i].s_tile,f))
50606 {
50607 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",11);
50608 }
50609
50610 if(!p_putc(guysbuf[i].s_width,f))
50611 {
50612 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",12);
50613 }
50614
50615 if(!p_putc(guysbuf[i].s_height,f))
50616 {
50617 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",13);
50618 }
50619
50620 if(!p_iputl(guysbuf[i].e_tile,f))
50621 {
50622 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",14);
50623 }
50624
50625 if(!p_putc(guysbuf[i].e_width,f))
50626 {
50627 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",15);
50628 }
50629
50630 if(!p_putc(guysbuf[i].e_height,f))
50631 {
50632 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",16);
50633 }
50634
50635 if(!p_iputw(guysbuf[i].hp,f))
50636 {
50637 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",17);
50638 }
50639
50640 if(!p_iputw(guysbuf[i].family,f))
50641 {
50642 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",18);
50643 }
50644
50645 if(!p_iputw(guysbuf[i].cset,f))
50646 {
50647 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",19);
50648 }
50649
50650 if(!p_iputw(guysbuf[i].anim,f))
50651 {
50652 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",20);
50653 }
50654
50655 if(!p_iputw(guysbuf[i].e_anim,f))
50656 {
50657 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",21);
50658 }
50659
50660 if(!p_iputw(guysbuf[i].frate,f))
50661 {
50662 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",22);
50663 }
50664
50665 if(!p_iputw(guysbuf[i].e_frate,f))
50666 {
50667 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",23);
50668 }
50669
50670 if(!p_iputw(guysbuf[i].dp,f))
50671 {
50672 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",24);
50673 }
50674
50675 if(!p_iputw(guysbuf[i].wdp,f))
50676 {
50677 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",25);
50678 }
50679
50680 if(!p_iputw(guysbuf[i].weapon,f))
50681 {
50682 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",26);
50683 }
50684
50685 if(!p_iputw(guysbuf[i].rate,f))
50686 {
50687 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",27);
50688 }
50689
50690 if(!p_iputw(guysbuf[i].hrate,f))
50691 {
50692 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",28);
50693 }
50694
50695 if(!p_iputw(guysbuf[i].step,f))
50696 {
50697 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",29);
50698 }
50699
50700 if(!p_iputw(guysbuf[i].homing,f))
50701 {
50702 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",30);
50703 }
50704
50705 if(!p_iputw(guysbuf[i].grumble,f))
50706 {
50707 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",31);
50708 }
50709
50710 if(!p_iputw(guysbuf[i].item_set,f))
50711 {
50712 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",32);
50713 }
50714
50715 if(!p_iputl(guysbuf[i].misc1,f))
50716 {
50717 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",33);
50718 }
50719
50720 if(!p_iputl(guysbuf[i].misc2,f))
50721 {
50722 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",34);
50723 }
50724
50725 if(!p_iputl(guysbuf[i].misc3,f))
50726 {
50727 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",35);
50728 }
50729
50730 if(!p_iputl(guysbuf[i].misc4,f))
50731 {
50732 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",36);
50733 }
50734
50735 if(!p_iputl(guysbuf[i].misc5,f))
50736 {
50737 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",37);
50738 }
50739
50740 if(!p_iputl(guysbuf[i].misc6,f))
50741 {
50742 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",38);
50743 }
50744
50745 if(!p_iputl(guysbuf[i].misc7,f))
50746 {
50747 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",39);
50748 }
50749
50750 if(!p_iputl(guysbuf[i].misc8,f))
50751 {
50752 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",40);
50753 }
50754
50755 if(!p_iputl(guysbuf[i].misc9,f))
50756 {
50757 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",41);
50758 }
50759
50760 if(!p_iputl(guysbuf[i].misc10,f))
50761 {
50762 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",42);
50763 }
50764
50765 if(!p_iputw(guysbuf[i].bgsfx,f))
50766 {
50767 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",43);
50768 }
50769
50770 if(!p_iputw(guysbuf[i].bosspal,f))
50771 {
50772 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",44);
50773 }
50774
50775 if(!p_iputw(guysbuf[i].extend,f))
50776 {
50777 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",45);
50778 }
50779
50780 for(int32_t j=0; j < edefLAST; j++)
50781 {
50782 if(!p_putc(guysbuf[i].defense[j],f))
50783 {
50784 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",46);
50785 }
50786 }
50787
50788 if(!p_putc(guysbuf[i].hitsfx,f))
50789 {
50790 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",47);
50791 }
50792
50793 if(!p_putc(guysbuf[i].deadsfx,f))
50794 {
50795 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",48);
50796 }
50797
50798 if(!p_iputl(guysbuf[i].misc11,f))
50799 {
50800 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",49);
50801 }
50802
50803 if(!p_iputl(guysbuf[i].misc12,f))
50804 {
50805 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",50);
50806 }
50807
50808 //New 2.6 defences
50809 for(int32_t j=edefLAST; j < edefLAST255; j++)
50810 {
50811 if(!p_putc(guysbuf[i].defense[j],f))
50812 {
50813 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",51);
50814 }
50815 }
50816
50817 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
50818 if(!p_iputl(guysbuf[i].txsz,f))
50819 {
50820 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",52);
50821 }
50822 if(!p_iputl(guysbuf[i].tysz,f))
50823 {
50824 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",53);
50825 }
50826 if(!p_iputl(guysbuf[i].hxsz,f))
50827 {
50828 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",54);
50829 }
50830 if(!p_iputl(guysbuf[i].hysz,f))
50831 {
50832 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",55);
50833 }
50834 if(!p_iputl(guysbuf[i].hzsz,f))
50835 {
50836 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",56);
50837 }
50838 // These are not fixed types, but ints, so they are safe to use here.
50839 if(!p_iputl(guysbuf[i].hxofs,f))
50840 {
50841 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",57);
50842 }
50843 if(!p_iputl(guysbuf[i].hyofs,f))
50844 {
50845 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",58);
50846 }
50847 if(!p_iputl(guysbuf[i].xofs,f))
50848 {
50849 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",59);
50850 }
50851 if(!p_iputl(guysbuf[i].yofs,f))
50852 {
50853 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",60);
50854 }
50855 if(!p_iputl(guysbuf[i].zofs,f))
50856 {
50857 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",61);
50858 }
50859 if(!p_iputl(guysbuf[i].wpnsprite,f))
50860 {
50861 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",62);
50862 }
50863 if(!p_iputl(guysbuf[i].SIZEflags,f))
50864 {
50865 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",63);
50866 }
50867 if(!p_iputl(guysbuf[i].frozentile,f))
50868 {
50869 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",64);
50870 }
50871 if(!p_iputl(guysbuf[i].frozencset,f))
50872 {
50873 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",65);
50874 }
50875 if(!p_iputl(guysbuf[i].frozenclock,f))
50876 {
50877 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",66);
50878 }
50879
50880 for ( int32_t q = 0; q < 10; q++ )
50881 {
50882 if(!p_iputw(guysbuf[i].frozenmisc[q],f))
50883 {
50884 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",67);
50885 }
50886 }
50887 if(!p_iputw(guysbuf[i].firesfx,f))
50888 {
50889 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",68);
50890 }
50891 //misc 16->31
50892 if(!p_iputl(guysbuf[i].misc16,f))
50893 {
50894 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",69);
50895 }
50896 if(!p_iputl(guysbuf[i].misc17,f))
50897 {
50898 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",70);
50899 }
50900 if(!p_iputl(guysbuf[i].misc18,f))
50901 {
50902 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",71);
50903 }
50904 if(!p_iputl(guysbuf[i].misc19,f))
50905 {
50906 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",72);
50907 }
50908 if(!p_iputl(guysbuf[i].misc20,f))
50909 {
50910 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",73);
50911 }
50912 if(!p_iputl(guysbuf[i].misc21,f))
50913 {
50914 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",74);
50915 }
50916 if(!p_iputl(guysbuf[i].misc22,f))
50917 {
50918 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",75);
50919 }
50920 if(!p_iputl(guysbuf[i].misc23,f))
50921 {
50922 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",76);
50923 }
50924 if(!p_iputl(guysbuf[i].misc24,f))
50925 {
50926 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",77);
50927 }
50928 if(!p_iputl(guysbuf[i].misc25,f))
50929 {
50930 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",78);
50931 }
50932 if(!p_iputl(guysbuf[i].misc26,f))
50933 {
50934 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",79);
50935 }
50936 if(!p_iputl(guysbuf[i].misc27,f))
50937 {
50938 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",80);
50939 }
50940 if(!p_iputl(guysbuf[i].misc28,f))
50941 {
50942 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",81);
50943 }
50944 if(!p_iputl(guysbuf[i].misc29,f))
50945 {
50946 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",82);
50947 }
50948 if(!p_iputl(guysbuf[i].misc30,f))
50949 {
50950 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",83);
50951 }
50952 if(!p_iputl(guysbuf[i].misc31,f))
50953 {
50954 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",84);
50955 }
50956 if(!p_iputl(guysbuf[i].misc32,f))
50957 {
50958 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",85);
50959 }
50960 for ( int32_t q = 0; q < 32; q++ )
50961 {
50962 if(!p_iputl(guysbuf[i].movement[q],f))
50963 {
50964 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",86);
50965 }
50966 }
50967 for ( int32_t q = 0; q < 32; q++ )
50968 {
50969 if(!p_iputl(guysbuf[i].new_weapon[q],f))
50970 {
50971 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",87);
50972 }
50973 }
50974 if(!p_iputw(guysbuf[i].script,f))
50975 {
50976 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",88);
50977 }
50978 for ( int32_t q = 0; q < 8; q++ )
50979 {
50980 if(!p_iputl(guysbuf[i].initD[q],f))
50981 {
50982 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",89);
50983 }
50984 }
50985 for ( int32_t q = 0; q < 2; q++ )
50986 {
50987 if(!p_iputl(guysbuf[i].initA[q],f))
50988 {
50989 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",90);
50990 }
50991 }
50992 if(!p_iputl(guysbuf[i].editorflags,f))
50993 {
50994 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",91);
50995 }
50996 //somehow forgot these in the older builds -Z
50997 if(!p_iputl(guysbuf[i].misc13,f))
50998 {
50999 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",92);
51000 }
51001 if(!p_iputl(guysbuf[i].misc14,f))
51002 {
51003 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",93);
51004 }
51005 if(!p_iputl(guysbuf[i].misc15,f))
51006 {
51007 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",94);
51008 }
51009
51010 //Enemy Editor InitD[] labels
51011 for ( int32_t q = 0; q < 8; q++ )
51012 {
51013 for ( int32_t w = 0; w < 65; w++ )
51014 {
51015 if(!p_putc(guysbuf[i].initD_label[q][w],f))
51016 {
51017 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",95);
51018 }
51019 }
51020 for ( int32_t w = 0; w < 65; w++ )
51021 {
51022 if(!p_putc(guysbuf[i].weapon_initD_label[q][w],f))
51023 {
51024 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",96);
51025 }
51026 }
51027 }
51028 if(!p_iputw(guysbuf[i].weaponscript,f))
51029 {
51030 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",97);
51031 }
51032 //eweapon initD
51033 for ( int32_t q = 0; q < 8; q++ )
51034 {
51035 if(!p_iputl(guysbuf[i].weap_initiald[q],f))
51036 {
51037 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",98);
51038 }
51039 }
51040
51041 }
51042 }
51043
51044
51045 void FFScript::write_items(PACKFILE *f, int32_t vers_id)
51046 {
51047 for(int32_t i=0; i<MAXITEMS; i++)
51048 {
51049 if(!p_iputl(itemsbuf[i].tile,f))
51050 {
51051 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",6);
51052 }
51053
51054 if(!p_putc(itemsbuf[i].misc_flags,f))
51055 {
51056 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",7);
51057 }
51058
51059 if(!p_putc(itemsbuf[i].csets,f))
51060 {
51061 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",8);
51062 }
51063
51064 if(!p_putc(itemsbuf[i].frames,f))
51065 {
51066 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",9);
51067 }
51068
51069 if(!p_putc(itemsbuf[i].speed,f))
51070 {
51071 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",10);
51072 }
51073
51074 if(!p_putc(itemsbuf[i].delay,f))
51075 {
51076 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",11);
51077 }
51078
51079 if(!p_iputl(itemsbuf[i].ltm,f))
51080 {
51081 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",12);
51082 }
51083
51084 if(!p_iputl(itemsbuf[i].family,f))
51085 {
51086 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",13);
51087 }
51088
51089 if(!p_putc(itemsbuf[i].fam_type,f))
51090 {
51091 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",14);
51092 }
51093
51094 if(!p_iputl(itemsbuf[i].power,f))
51095 {
51096 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",14);
51097 }
51098
51099 if(!p_iputl(itemsbuf[i].flags,f))
51100 {
51101 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",15);
51102 }
51103
51104 if(!p_iputw(itemsbuf[i].script,f))
51105 {
51106 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",16);
51107 }
51108
51109 if(!p_putc(itemsbuf[i].count,f))
51110 {
51111 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",17);
51112 }
51113
51114 if(!p_iputw(itemsbuf[i].amount,f))
51115 {
51116 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",18);
51117 }
51118
51119 if(!p_iputw(itemsbuf[i].collect_script,f))
51120 {
51121 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",19);
51122 }
51123
51124 if(!p_iputw(itemsbuf[i].setmax,f))
51125 {
51126 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",21);
51127 }
51128
51129 if(!p_iputw(itemsbuf[i].max,f))
51130 {
51131 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",22);
51132 }
51133
51134 if(!p_putc(itemsbuf[i].playsound,f))
51135 {
51136 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",23);
51137 }
51138
51139 for(int32_t j=0; j<8; j++)
51140 {
51141 if(!p_iputl(itemsbuf[i].initiald[j],f))
51142 {
51143 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",24);
51144 }
51145 }
51146
51147 for(int32_t j=0; j<2; j++)
51148 {
51149 if(!p_putc(itemsbuf[i].initiala[j],f))
51150 {
51151 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",25);
51152 }
51153 }
51154
51155 if(!p_putc(itemsbuf[i].wpn,f))
51156 {
51157 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",26);
51158 }
51159
51160 if(!p_putc(itemsbuf[i].wpn2,f))
51161 {
51162 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",27);
51163 }
51164
51165 if(!p_putc(itemsbuf[i].wpn3,f))
51166 {
51167 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",28);
51168 }
51169
51170 if(!p_putc(itemsbuf[i].wpn4,f))
51171 {
51172 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",29);
51173 }
51174
51175 if(!p_putc(itemsbuf[i].wpn5,f))
51176 {
51177 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",30);
51178 }
51179
51180 if(!p_putc(itemsbuf[i].wpn6,f))
51181 {
51182 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",31);
51183 }
51184
51185 if(!p_putc(itemsbuf[i].wpn7,f))
51186 {
51187 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",32);
51188 }
51189
51190 if(!p_putc(itemsbuf[i].wpn8,f))
51191 {
51192 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",33);
51193 }
51194
51195 if(!p_putc(itemsbuf[i].wpn9,f))
51196 {
51197 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",34);
51198 }
51199
51200 if(!p_putc(itemsbuf[i].wpn10,f))
51201 {
51202 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",35);
51203 }
51204
51205 if(!p_putc(itemsbuf[i].pickup_hearts,f))
51206 {
51207 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",36);
51208 }
51209
51210 if(!p_iputl(itemsbuf[i].misc1,f))
51211 {
51212 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",37);
51213 }
51214
51215 if(!p_iputl(itemsbuf[i].misc2,f))
51216 {
51217 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",38);
51218 }
51219
51220 if(!p_putc(itemsbuf[i].cost_amount[0],f))
51221 {
51222 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",39);
51223 }
51224
51225 if(!p_iputl(itemsbuf[i].misc3,f))
51226 {
51227 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",40);
51228 }
51229
51230 if(!p_iputl(itemsbuf[i].misc4,f))
51231 {
51232 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",41);
51233 }
51234
51235 if(!p_iputl(itemsbuf[i].misc5,f))
51236 {
51237 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",42);
51238 }
51239
51240 if(!p_iputl(itemsbuf[i].misc6,f))
51241 {
51242 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",43);
51243 }
51244
51245 if(!p_iputl(itemsbuf[i].misc7,f))
51246 {
51247 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",44);
51248 }
51249
51250 if(!p_iputl(itemsbuf[i].misc8,f))
51251 {
51252 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",45);
51253 }
51254
51255 if(!p_iputl(itemsbuf[i].misc9,f))
51256 {
51257 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",46);
51258 }
51259
51260 if(!p_iputl(itemsbuf[i].misc10,f))
51261 {
51262 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",47);
51263 }
51264
51265 if(!p_putc(itemsbuf[i].usesound,f))
51266 {
51267 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",48);
51268 }
51269
51270 if(!p_putc(itemsbuf[i].usesound2,f))
51271 {
51272 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",48);
51273 }
51274
51275 //New itemdata vars -Z
51276 //! version 27
51277
51278 if(!p_putc(itemsbuf[i].useweapon,f))
51279 {
51280 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",49);
51281 }
51282 if(!p_putc(itemsbuf[i].usedefence,f))
51283 {
51284 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",50);
51285 }
51286 if(!p_iputl(itemsbuf[i].weaprange,f))
51287 {
51288 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",51);
51289 }
51290 if(!p_iputl(itemsbuf[i].weapduration,f))
51291 {
51292 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",52);
51293 }
51294 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ ) {
51295 if(!p_iputl(itemsbuf[i].weap_pattern[q],f))
51296 {
51297 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",53);
51298 }
51299 }
51300 //version 28
51301 if(!p_iputl(itemsbuf[i].duplicates,f))
51302 {
51303 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",54);
51304 }
51305 for ( int32_t q = 0; q < INITIAL_D; q++ )
51306 {
51307 if(!p_iputl(itemsbuf[i].weap_initiald[q],f))
51308 {
51309 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",55);
51310 }
51311 }
51312 for ( int32_t q = 0; q < INITIAL_A; q++ )
51313 {
51314 if(!p_putc(itemsbuf[i].weap_initiala[q],f))
51315 {
51316 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",56);
51317 }
51318 }
51319
51320 if(!p_putc(itemsbuf[i].drawlayer,f))
51321 {
51322 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",57);
51323 }
51324
51325
51326 if(!p_iputl(itemsbuf[i].hxofs,f))
51327 {
51328 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",58);
51329 }
51330 if(!p_iputl(itemsbuf[i].hyofs,f))
51331 {
51332 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",59);
51333 }
51334 if(!p_iputl(itemsbuf[i].hxsz,f))
51335 {
51336 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",60);
51337 }
51338 if(!p_iputl(itemsbuf[i].hysz,f))
51339 {
51340 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",61);
51341 }
51342 if(!p_iputl(itemsbuf[i].hzsz,f))
51343 {
51344 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",62);
51345 }
51346 if(!p_iputl(itemsbuf[i].xofs,f))
51347 {
51348 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",63);
51349 }
51350 if(!p_iputl(itemsbuf[i].yofs,f))
51351 {
51352 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",64);
51353 }
51354 if(!p_iputl(itemsbuf[i].weap_hxofs,f))
51355 {
51356 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",65);
51357 }
51358 if(!p_iputl(itemsbuf[i].weap_hyofs,f))
51359 {
51360 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",66);
51361 }
51362 if(!p_iputl(itemsbuf[i].weap_hxsz,f))
51363 {
51364 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",67);
51365 }
51366 if(!p_iputl(itemsbuf[i].weap_hysz,f))
51367 {
51368 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",68);
51369 }
51370 if(!p_iputl(itemsbuf[i].weap_hzsz,f))
51371 {
51372 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",69);
51373 }
51374 if(!p_iputl(itemsbuf[i].weap_xofs,f))
51375 {
51376 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",70);
51377 }
51378 if(!p_iputl(itemsbuf[i].weap_yofs,f))
51379 {
51380 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",71);
51381 }
51382 if(!p_iputw(itemsbuf[i].weaponscript,f))
51383 {
51384 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",72);
51385 }
51386 if(!p_iputl(itemsbuf[i].wpnsprite,f))
51387 {
51388 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",73);
51389 }
51390 if(!p_iputl(itemsbuf[i].magiccosttimer[0],f))
51391 {
51392 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",74);
51393 }
51394 if(!p_iputl(itemsbuf[i].overrideFLAGS,f))
51395 {
51396 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",75);
51397 }
51398 if(!p_iputl(itemsbuf[i].tilew,f))
51399 {
51400 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",76);
51401 }
51402 if(!p_iputl(itemsbuf[i].tileh,f))
51403 {
51404 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",77);
51405 }
51406 if(!p_iputl(itemsbuf[i].weapoverrideFLAGS,f))
51407 {
51408 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",78);
51409 }
51410 if(!p_iputl(itemsbuf[i].weap_tilew,f))
51411 {
51412 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",79);
51413 }
51414 if(!p_iputl(itemsbuf[i].weap_tileh,f))
51415 {
51416 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",80);
51417 }
51418 if(!p_iputl(itemsbuf[i].pickup,f))
51419 {
51420 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",81);
51421 }
51422 if(!p_iputw(itemsbuf[i].pstring,f))
51423 {
51424 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",82);
51425 }
51426 if(!p_iputw(itemsbuf[i].pickup_string_flags,f))
51427 {
51428 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",83);
51429 }
51430
51431 if(!p_putc(itemsbuf[i].cost_counter[0],f))
51432 {
51433 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",84);
51434 }
51435
51436 //InitD[] labels
51437 for ( int32_t q = 0; q < 8; q++ )
51438 {
51439 for ( int32_t w = 0; w < 65; w++ )
51440 {
51441 if(!p_putc(itemsbuf[i].initD_label[q][w],f))
51442 {
51443 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",85);
51444 }
51445 }
51446 for ( int32_t w = 0; w < 65; w++ )
51447 {
51448 if(!p_putc(itemsbuf[i].weapon_initD_label[q][w],f))
51449 {
51450 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",86);
51451 }
51452 }
51453 for ( int32_t w = 0; w < 65; w++ )
51454 {
51455 if(!p_putc(itemsbuf[i].sprite_initD_label[q][w],f))
51456 {
51457 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",87);
51458 }
51459 }
51460 if(!p_iputl(itemsbuf[i].sprite_initiald[q],f))
51461 {
51462 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",88);
51463 }
51464 }
51465 for ( int32_t q = 0; q < 2; q++ )
51466 {
51467 if(!p_putc(itemsbuf[i].sprite_initiala[q],f))
51468 {
51469 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",89);
51470 }
51471
51472 }
51473 if(!p_iputw(itemsbuf[i].sprite_script,f))
51474 {
51475 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",90);
51476 }
51477
51478
51479 }
51480 }
51481
51482 void FFScript::read_items(PACKFILE *f, int32_t vers_id)
51483 {
51484 for(int32_t i=0; i<MAXITEMS; i++)
51485 {
51486 if(!p_igetl(&itemsbuf[i].tile,f))
51487 {
51488 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",6);
51489 }
51490
51491 if(!p_getc(&itemsbuf[i].misc_flags,f))
51492 {
51493 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",7);
51494 }
51495
51496 if(!p_getc(&itemsbuf[i].csets,f))
51497 {
51498 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",8);
51499 }
51500
51501 if(!p_getc(&itemsbuf[i].frames,f))
51502 {
51503 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",9);
51504 }
51505
51506 if(!p_getc(&itemsbuf[i].speed,f))
51507 {
51508 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",10);
51509 }
51510
51511 if(!p_getc(&itemsbuf[i].delay,f))
51512 {
51513 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",11);
51514 }
51515
51516 if(!p_igetl(&itemsbuf[i].ltm,f))
51517 {
51518 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",12);
51519 }
51520
51521 if(!p_igetl(&itemsbuf[i].family,f))
51522 {
51523 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",13);
51524 }
51525
51526 if(!p_getc(&itemsbuf[i].fam_type,f))
51527 {
51528 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",14);
51529 }
51530
51531 if(!p_igetl(&itemsbuf[i].power,f))
51532 {
51533 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",14);
51534 }
51535
51536 if(!p_igetl(&itemsbuf[i].flags,f))
51537 {
51538 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",15);
51539 }
51540
51541 if(!p_igetw(&itemsbuf[i].script,f))
51542 {
51543 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",16);
51544 }
51545
51546 if(!p_getc(&itemsbuf[i].count,f))
51547 {
51548 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",17);
51549 }
51550
51551 if(!p_igetw(&itemsbuf[i].amount,f))
51552 {
51553 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",18);
51554 }
51555
51556 if(!p_igetw(&itemsbuf[i].collect_script,f))
51557 {
51558 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",19);
51559 }
51560
51561 if(!p_igetw(&itemsbuf[i].setmax,f))
51562 {
51563 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",21);
51564 }
51565
51566 if(!p_igetw(&itemsbuf[i].max,f))
51567 {
51568 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",22);
51569 }
51570
51571 if(!p_getc(&itemsbuf[i].playsound,f))
51572 {
51573 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",23);
51574 }
51575
51576 for(int32_t j=0; j<8; j++)
51577 {
51578 if(!p_igetl(&itemsbuf[i].initiald[j],f))
51579 {
51580 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",24);
51581 }
51582 }
51583
51584 for(int32_t j=0; j<2; j++)
51585 {
51586 if(!p_getc(&itemsbuf[i].initiala[j],f))
51587 {
51588 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",25);
51589 }
51590 }
51591
51592 if(!p_getc(&itemsbuf[i].wpn,f))
51593 {
51594 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",26);
51595 }
51596
51597 if(!p_getc(&itemsbuf[i].wpn2,f))
51598 {
51599 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",27);
51600 }
51601
51602 if(!p_getc(&itemsbuf[i].wpn3,f))
51603 {
51604 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",28);
51605 }
51606
51607 if(!p_getc(&itemsbuf[i].wpn4,f))
51608 {
51609 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",29);
51610 }
51611
51612 if(!p_getc(&itemsbuf[i].wpn5,f))
51613 {
51614 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",30);
51615 }
51616
51617 if(!p_getc(&itemsbuf[i].wpn6,f))
51618 {
51619 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",31);
51620 }
51621
51622 if(!p_getc(&itemsbuf[i].wpn7,f))
51623 {
51624 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",32);
51625 }
51626
51627 if(!p_getc(&itemsbuf[i].wpn8,f))
51628 {
51629 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",33);
51630 }
51631
51632 if(!p_getc(&itemsbuf[i].wpn9,f))
51633 {
51634 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",34);
51635 }
51636
51637 if(!p_getc(&itemsbuf[i].wpn10,f))
51638 {
51639 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",35);
51640 }
51641
51642 if(!p_getc(&itemsbuf[i].pickup_hearts,f))
51643 {
51644 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",36);
51645 }
51646
51647 if(!p_igetl(&itemsbuf[i].misc1,f))
51648 {
51649 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",37);
51650 }
51651
51652 if(!p_igetl(&itemsbuf[i].misc2,f))
51653 {
51654 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",38);
51655 }
51656
51657 if(!p_getc(&itemsbuf[i].cost_amount[0],f))
51658 {
51659 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",39);
51660 }
51661
51662 if(!p_igetl(&itemsbuf[i].misc3,f))
51663 {
51664 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",40);
51665 }
51666
51667 if(!p_igetl(&itemsbuf[i].misc4,f))
51668 {
51669 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",41);
51670 }
51671
51672 if(!p_igetl(&itemsbuf[i].misc5,f))
51673 {
51674 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",42);
51675 }
51676
51677 if(!p_igetl(&itemsbuf[i].misc6,f))
51678 {
51679 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",43);
51680 }
51681
51682 if(!p_igetl(&itemsbuf[i].misc7,f))
51683 {
51684 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",44);
51685 }
51686
51687 if(!p_igetl(&itemsbuf[i].misc8,f))
51688 {
51689 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",45);
51690 }
51691
51692 if(!p_igetl(&itemsbuf[i].misc9,f))
51693 {
51694 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",46);
51695 }
51696
51697 if(!p_igetl(&itemsbuf[i].misc10,f))
51698 {
51699 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",47);
51700 }
51701
51702 if(!p_getc(&itemsbuf[i].usesound,f))
51703 {
51704 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",48);
51705 }
51706
51707 if(!p_getc(&itemsbuf[i].usesound2,f))
51708 {
51709 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",48);
51710 }
51711
51712 //New itemdata vars -Z
51713 //! version 27
51714
51715 if(!p_getc(&itemsbuf[i].useweapon,f))
51716 {
51717 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",49);
51718 }
51719 if(!p_getc(&itemsbuf[i].usedefence,f))
51720 {
51721 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",50);
51722 }
51723 if(!p_igetl(&itemsbuf[i].weaprange,f))
51724 {
51725 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",51);
51726 }
51727 if(!p_igetl(&itemsbuf[i].weapduration,f))
51728 {
51729 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",52);
51730 }
51731 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ ) {
51732 if(!p_igetl(&itemsbuf[i].weap_pattern[q],f))
51733 {
51734 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",53);
51735 }
51736 }
51737 //version 28
51738 if(!p_igetl(&itemsbuf[i].duplicates,f))
51739 {
51740 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",54);
51741 }
51742 for ( int32_t q = 0; q < INITIAL_D; q++ )
51743 {
51744 if(!p_igetl(&itemsbuf[i].weap_initiald[q],f))
51745 {
51746 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",55);
51747 }
51748 }
51749 for ( int32_t q = 0; q < INITIAL_A; q++ )
51750 {
51751 if(!p_getc(&itemsbuf[i].weap_initiala[q],f))
51752 {
51753 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",56);
51754 }
51755 }
51756
51757 if(!p_getc(&itemsbuf[i].drawlayer,f))
51758 {
51759 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",57);
51760 }
51761
51762
51763 if(!p_igetl(&itemsbuf[i].hxofs,f))
51764 {
51765 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",58);
51766 }
51767 if(!p_igetl(&itemsbuf[i].hyofs,f))
51768 {
51769 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",59);
51770 }
51771 if(!p_igetl(&itemsbuf[i].hxsz,f))
51772 {
51773 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",60);
51774 }
51775 if(!p_igetl(&itemsbuf[i].hysz,f))
51776 {
51777 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",61);
51778 }
51779 if(!p_igetl(&itemsbuf[i].hzsz,f))
51780 {
51781 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",62);
51782 }
51783 if(!p_igetl(&itemsbuf[i].xofs,f))
51784 {
51785 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",63);
51786 }
51787 if(!p_igetl(&itemsbuf[i].yofs,f))
51788 {
51789 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",64);
51790 }
51791 if(!p_igetl(&itemsbuf[i].weap_hxofs,f))
51792 {
51793 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",65);
51794 }
51795 if(!p_igetl(&itemsbuf[i].weap_hyofs,f))
51796 {
51797 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",66);
51798 }
51799 if(!p_igetl(&itemsbuf[i].weap_hxsz,f))
51800 {
51801 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",67);
51802 }
51803 if(!p_igetl(&itemsbuf[i].weap_hysz,f))
51804 {
51805 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",68);
51806 }
51807 if(!p_igetl(&itemsbuf[i].weap_hzsz,f))
51808 {
51809 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",69);
51810 }
51811 if(!p_igetl(&itemsbuf[i].weap_xofs,f))
51812 {
51813 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",70);
51814 }
51815 if(!p_igetl(&itemsbuf[i].weap_yofs,f))
51816 {
51817 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",71);
51818 }
51819 if(!p_igetw(&itemsbuf[i].weaponscript,f))
51820 {
51821 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",72);
51822 }
51823 if(!p_igetl(&itemsbuf[i].wpnsprite,f))
51824 {
51825 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",73);
51826 }
51827 if(!p_igetl(&itemsbuf[i].magiccosttimer[0],f))
51828 {
51829 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",74);
51830 }
51831 if(!p_igetl(&itemsbuf[i].overrideFLAGS,f))
51832 {
51833 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",75);
51834 }
51835 if(!p_igetl(&itemsbuf[i].tilew,f))
51836 {
51837 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",76);
51838 }
51839 if(!p_igetl(&itemsbuf[i].tileh,f))
51840 {
51841 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",77);
51842 }
51843 if(!p_igetl(&itemsbuf[i].weapoverrideFLAGS,f))
51844 {
51845 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",78);
51846 }
51847 if(!p_igetl(&itemsbuf[i].weap_tilew,f))
51848 {
51849 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",79);
51850 }
51851 if(!p_igetl(&itemsbuf[i].weap_tileh,f))
51852 {
51853 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",80);
51854 }
51855 if(!p_igetl(&itemsbuf[i].pickup,f))
51856 {
51857 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",81);
51858 }
51859 if(!p_igetw(&itemsbuf[i].pstring,f))
51860 {
51861 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",82);
51862 }
51863 if(!p_igetw(&itemsbuf[i].pickup_string_flags,f))
51864 {
51865 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",83);
51866 }
51867
51868 if(!p_getc(&itemsbuf[i].cost_counter[0],f))
51869 {
51870 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",84);
51871 }
51872
51873 //InitD[] labels
51874 for ( int32_t q = 0; q < 8; q++ )
51875 {
51876 for ( int32_t w = 0; w < 65; w++ )
51877 {
51878 if(!p_getc(&itemsbuf[i].initD_label[q][w],f))
51879 {
51880 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",85);
51881 }
51882 }
51883 for ( int32_t w = 0; w < 65; w++ )
51884 {
51885 if(!p_getc(&itemsbuf[i].weapon_initD_label[q][w],f))
51886 {
51887 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",86);
51888 }
51889 }
51890 for ( int32_t w = 0; w < 65; w++ )
51891 {
51892 if(!p_getc(&itemsbuf[i].sprite_initD_label[q][w],f))
51893 {
51894 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",87);
51895 }
51896 }
51897 if(!p_igetl(&itemsbuf[i].sprite_initiald[q],f))
51898 {
51899 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",88);
51900 }
51901 }
51902 for ( int32_t q = 0; q < 2; q++ )
51903 {
51904 if(!p_getc(&itemsbuf[i].sprite_initiala[q],f))
51905 {
51906 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",89);
51907 }
51908
51909 }
51910 if(!p_igetw(&itemsbuf[i].sprite_script,f))
51911 {
51912 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",90);
51913 }
51914
51915
51916 }
51917 }
51918
51919 void FFScript::write_mapscreens(PACKFILE *f,int32_t vers_id)
51920 {
51921 for(int32_t i=0; i<map_count && i<MAXMAPS; i++)
51922 {
51923 for(int32_t j=0; j<MAPSCRS; j++)
51924 {
51925 mapscr *m = &TheMaps[i*MAPSCRS+j];
51926
51927 if(!p_putc(m->valid,f))
51928 {
51929 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51930 }
51931
51932 if(!p_putc(m->guy,f))
51933 {
51934 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51935 }
51936
51937 {
51938 if(!p_iputw(m->str,f))
51939 {
51940 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51941 }
51942 }
51943
51944 if(!p_putc(m->room,f))
51945 {
51946 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51947 }
51948
51949 if(!p_putc(m->item,f))
51950 {
51951 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51952 }
51953
51954 if(!p_putc(m->hasitem, f))
51955 {
51956 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51957 }
51958
51959 for(int32_t k=0; k<4; k++)
51960 {
51961 if(!p_putc(m->tilewarptype[k],f))
51962 {
51963 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51964 }
51965 }
51966
51967 if(!p_iputw(m->door_combo_set,f))
51968 {
51969 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51970 }
51971
51972 for(int32_t k=0; k<4; k++)
51973 {
51974 if(!p_putc(m->warpreturnx[k],f))
51975 {
51976 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51977 }
51978 }
51979
51980 for(int32_t k=0; k<4; k++)
51981 {
51982 if(!p_putc(m->warpreturny[k],f))
51983 {
51984 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51985 }
51986 }
51987
51988 if(!p_iputw(m->warpreturnc,f))
51989 {
51990 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51991 }
51992
51993 if(!p_putc(m->stairx,f))
51994 {
51995 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51996 }
51997
51998 if(!p_putc(m->stairy,f))
51999 {
52000 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52001 }
52002
52003 if(!p_putc(m->itemx,f))
52004 {
52005 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52006 }
52007
52008 if(!p_putc(m->itemy,f))
52009 {
52010 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52011 }
52012
52013 if(!p_iputw(m->color,f))
52014 {
52015 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52016 }
52017
52018 if(!p_putc(m->enemyflags,f))
52019 {
52020 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52021 }
52022
52023 for(int32_t k=0; k<4; k++)
52024 {
52025 if(!p_putc(m->door[k],f))
52026 {
52027 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52028 }
52029 }
52030
52031 for(int32_t k=0; k<4; k++)
52032 {
52033 if(!p_iputw(m->tilewarpdmap[k],f))
52034 {
52035 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52036 }
52037 }
52038
52039 for(int32_t k=0; k<4; k++)
52040 {
52041 if(!p_putc(m->tilewarpscr[k],f))
52042 {
52043 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52044 }
52045 }
52046
52047 if(!p_putc(m->tilewarpoverlayflags,f))
52048 {
52049 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52050 }
52051
52052 if(!p_putc(m->exitdir,f))
52053 {
52054 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52055 }
52056
52057 for(int32_t k=0; k<10; k++)
52058 {
52059 {
52060 if(!p_iputw(m->enemy[k],f))
52061 {
52062 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52063 }
52064 }
52065 }
52066
52067 if(!p_putc(m->pattern,f))
52068 {
52069 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52070 }
52071
52072 for(int32_t k=0; k<4; k++)
52073 {
52074 if(!p_putc(m->sidewarptype[k],f))
52075 {
52076 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52077 }
52078 }
52079
52080 if(!p_putc(m->sidewarpoverlayflags,f))
52081 {
52082 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52083 }
52084
52085 if(!p_putc(m->warparrivalx,f))
52086 {
52087 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52088 }
52089
52090 if(!p_putc(m->warparrivaly,f))
52091 {
52092 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52093 }
52094
52095 for(int32_t k=0; k<4; k++)
52096 {
52097 if(!p_putc(m->path[k],f))
52098 {
52099 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52100 }
52101 }
52102
52103 for(int32_t k=0; k<4; k++)
52104 {
52105 if(!p_putc(m->sidewarpscr[k],f))
52106 {
52107 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52108 }
52109 }
52110
52111 for(int32_t k=0; k<4; k++)
52112 {
52113 if(!p_iputw(m->sidewarpdmap[k],f))
52114 {
52115 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52116 }
52117 }
52118
52119 if(!p_putc(m->sidewarpindex,f))
52120 {
52121 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52122 }
52123
52124 if(!p_iputw(m->undercombo,f))
52125 {
52126 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52127 }
52128
52129 if(!p_putc(m->undercset,f))
52130 {
52131 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52132 }
52133
52134 if(!p_iputw(m->catchall,f))
52135 {
52136 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52137 }
52138
52139 if(!p_putc(m->flags,f))
52140 {
52141 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52142 }
52143
52144 if(!p_putc(m->flags2,f))
52145 {
52146 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52147 }
52148
52149 if(!p_putc(m->flags3,f))
52150 {
52151 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52152 }
52153
52154 if(!p_putc(m->flags4,f))
52155 {
52156 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52157 }
52158
52159 if(!p_putc(m->flags5,f))
52160 {
52161 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52162 }
52163
52164 if(!p_iputw(m->noreset,f))
52165 {
52166 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52167 }
52168
52169 if(!p_iputw(m->nocarry,f))
52170 {
52171 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52172 }
52173
52174 if(!p_putc(m->flags6,f))
52175 {
52176 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52177 }
52178
52179 if(!p_putc(m->flags7,f))
52180 {
52181 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52182 }
52183
52184 if(!p_putc(m->flags8,f))
52185 {
52186 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52187 }
52188
52189 if(!p_putc(m->flags9,f))
52190 {
52191 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52192 }
52193
52194 if(!p_putc(m->flags10,f))
52195 {
52196 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52197 }
52198
52199 if(!p_putc(m->csensitive,f))
52200 {
52201 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52202 }
52203
52204 if(!p_putc(m->oceansfx,f))
52205 {
52206 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52207 }
52208
52209 if(!p_putc(m->bosssfx,f))
52210 {
52211 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52212 }
52213
52214 if(!p_putc(m->secretsfx,f))
52215 {
52216 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52217 }
52218
52219 if(!p_putc(m->holdupsfx,f))
52220 {
52221 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52222 }
52223
52224 for(int32_t k=0; k<6; k++)
52225 {
52226 if(!p_putc(m->layermap[k],f))
52227 {
52228 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52229 }
52230 }
52231
52232 for(int32_t k=0; k<6; k++)
52233 {
52234 if(!p_putc(m->layerscreen[k],f))
52235 {
52236 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52237 }
52238 }
52239
52240 for(int32_t k=0; k<6; k++)
52241 {
52242 if(!p_putc(m->layeropacity[k],f))
52243 {
52244 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52245 }
52246 }
52247
52248 if(!p_iputw(m->timedwarptics,f))
52249 {
52250 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52251 }
52252
52253 if(!p_putc(m->nextmap,f))
52254 {
52255 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52256 }
52257
52258 if(!p_putc(m->nextscr,f))
52259 {
52260 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52261 }
52262
52263 for(int32_t k=0; k<128; k++)
52264 {
52265 if(!p_iputw(m->secretcombo[k],f))
52266 {
52267 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52268 }
52269 }
52270
52271 for(int32_t k=0; k<128; k++)
52272 {
52273 if(!p_putc(m->secretcset[k],f))
52274 {
52275 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52276 }
52277 }
52278
52279 for(int32_t k=0; k<128; k++)
52280 {
52281 if(!p_putc(m->secretflag[k],f))
52282 {
52283 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52284 }
52285 }
52286
52287 for(int32_t k=0; k<176; k++)
52288 {
52289 try
52290 {
52291 if(!p_iputw(m->data[k],f))
52292 {
52293 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52294 }
52295 }
52296 catch(std::out_of_range& )
52297 {
52298 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52299 }
52300 }
52301
52302 for(int32_t k=0; k<176; k++)
52303 {
52304 try
52305 {
52306 if(!p_putc(m->sflag[k], f))
52307 {
52308 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52309 }
52310 }
52311 catch(std::out_of_range& )
52312 {
52313 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52314 }
52315 }
52316
52317 for(int32_t k=0; k<176; k++)
52318 {
52319 try
52320 {
52321 if(!p_putc(m->cset[k],f))
52322 {
52323 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52324 }
52325 }
52326 catch(std::out_of_range& )
52327 {
52328 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52329 }
52330 }
52331
52332 if(!p_iputw(m->screen_midi,f))
52333 {
52334 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52335 }
52336
52337 if(!p_putc(m->lens_layer,f))
52338 {
52339 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52340 }
52341
52342 for(int32_t k=0; k<32; k++)
52343 {
52344
52345 if(!p_iputw(m->ffcs[k].data,f))
52346 {
52347 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52348 }
52349
52350 if(!p_putc(m->ffcs[k].cset,f))
52351 {
52352 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52353 }
52354
52355 if(!p_iputw(m->ffcs[k].delay,f))
52356 {
52357 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52358 }
52359
52360 if(!p_iputzf(m->ffcs[k].x,f))
52361 {
52362 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52363 }
52364
52365 if(!p_iputzf(m->ffcs[k].y,f))
52366 {
52367 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52368 }
52369
52370 if(!p_iputzf(m->ffcs[k].vx,f))
52371 {
52372 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52373 }
52374
52375 if(!p_iputzf(m->ffcs[k].vy,f))
52376 {
52377 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52378 }
52379
52380 if(!p_iputzf(m->ffcs[k].ax,f))
52381 {
52382 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52383 }
52384
52385 if(!p_iputzf(m->ffcs[k].ay,f))
52386 {
52387 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52388 }
52389
52390 if(!p_putc(m->ffcs[k].link,f))
52391 {
52392 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52393 }
52394
52395 if(!p_iputl(m->ffcs[k].hit_width,f))
52396 {
52397 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52398 }
52399
52400 if(!p_iputl(m->ffcs[k].hit_height,f))
52401 {
52402 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52403 }
52404
52405 if(!p_putc(m->ffcs[k].txsz,f))
52406 {
52407 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52408 }
52409
52410 if(!p_putc(m->ffcs[k].tysz,f))
52411 {
52412 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52413 }
52414
52415 if(!p_iputl(m->ffcs[k].flags,f))
52416 {
52417 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52418 }
52419
52420 if(!p_iputw(m->ffcs[k].script,f))
52421 {
52422 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52423 }
52424
52425 if(!p_iputl(m->ffcs[k].initd[0],f))
52426 {
52427 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52428 }
52429
52430 if(!p_iputl(m->ffcs[k].initd[1],f))
52431 {
52432 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52433 }
52434
52435 if(!p_iputl(m->ffcs[k].initd[2],f))
52436 {
52437 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52438 }
52439
52440 if(!p_iputl(m->ffcs[k].initd[3],f))
52441 {
52442 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52443 }
52444
52445 if(!p_iputl(m->ffcs[k].initd[4],f))
52446 {
52447 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52448 }
52449
52450 if(!p_iputl(m->ffcs[k].initd[5],f))
52451 {
52452 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52453 }
52454
52455 if(!p_iputl(m->ffcs[k].initd[6],f))
52456 {
52457 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52458 }
52459
52460 if(!p_iputl(m->ffcs[k].initd[7],f))
52461 {
52462 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52463 }
52464
52465 }
52466
52467 for ( int32_t q = 0; q < 10; q++ )
52468 {
52469 if(!p_iputl(m->npcstrings[q],f))
52470 {
52471 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52472 }
52473 }
52474 for ( int32_t q = 0; q < 10; q++ )
52475 {
52476 if(!p_iputw(m->new_items[q],f))
52477 {
52478 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52479 }
52480 }
52481 for ( int32_t q = 0; q < 10; q++ )
52482 {
52483 if(!p_iputw(m->new_item_x[q],f))
52484 {
52485 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52486 }
52487 }
52488 for ( int32_t q = 0; q < 10; q++ )
52489 {
52490 if(!p_iputw(m->new_item_y[q],f))
52491 {
52492 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52493 }
52494 }
52495 if(!p_iputw(m->script,f))
52496 {
52497 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52498 }
52499 for ( int32_t q = 0; q < 8; q++ )
52500 {
52501 if(!p_iputl(m->screeninitd[q],f))
52502 {
52503 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52504 }
52505
52506 }
52507 if(!p_putc(m->preloadscript,f))
52508 {
52509 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52510 }
52511
52512 if(!p_putc(m->hidelayers,f))
52513 {
52514 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52515 }
52516 if(!p_putc(m->hidescriptlayers,f))
52517 {
52518 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52519 }
52520
52521
52522 } //end mapscr for loop
52523 }
52524 }
52525 void FFScript::read_mapscreens(PACKFILE *f,int32_t vers_id)
52526 {
52527 for(int32_t i=0; i<map_count && i<MAXMAPS; i++)
52528 {
52529 for(int32_t j=0; j<MAPSCRS; j++)
52530 {
52531 mapscr *m = &TheMaps[i*MAPSCRS+j];
52532
52533 if(!p_getc(&(m->valid),f))
52534 {
52535 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52536 }
52537
52538 if(!p_getc(&(m->guy),f))
52539 {
52540 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52541 }
52542
52543 {
52544 if(!p_igetw(&(m->str),f))
52545 {
52546 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52547 }
52548 }
52549
52550 if(!p_getc(&(m->room),f))
52551 {
52552 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52553 }
52554
52555 if(!p_getc(&(m->item),f))
52556 {
52557 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52558 }
52559
52560 if(!p_getc(&(m->hasitem), f))
52561 {
52562 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52563 }
52564
52565 for(int32_t k=0; k<4; k++)
52566 {
52567 if(!p_getc(&(m->tilewarptype[k]),f))
52568 {
52569 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52570 }
52571 }
52572
52573 if(!p_igetw(&(m->door_combo_set),f))
52574 {
52575 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52576 }
52577
52578 for(int32_t k=0; k<4; k++)
52579 {
52580 if(!p_getc(&(m->warpreturnx[k]),f))
52581 {
52582 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52583 }
52584 }
52585
52586 for(int32_t k=0; k<4; k++)
52587 {
52588 if(!p_getc(&(m->warpreturny[k]),f))
52589 {
52590 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52591 }
52592 }
52593
52594 if(!p_igetw(&(m->warpreturnc),f))
52595 {
52596 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52597 }
52598
52599 if(!p_getc(&(m->stairx),f))
52600 {
52601 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52602 }
52603
52604 if(!p_getc(&(m->stairy),f))
52605 {
52606 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52607 }
52608
52609 if(!p_getc(&(m->itemx),f))
52610 {
52611 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52612 }
52613
52614 if(!p_getc(&(m->itemy),f))
52615 {
52616 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52617 }
52618
52619 if(!p_igetw(&(m->color),f))
52620 {
52621 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52622 }
52623
52624 if(!p_getc(&(m->enemyflags),f))
52625 {
52626 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52627 }
52628
52629 for(int32_t k=0; k<4; k++)
52630 {
52631 if(!p_getc(&(m->door[k]),f))
52632 {
52633 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52634 }
52635 }
52636
52637 for(int32_t k=0; k<4; k++)
52638 {
52639 if(!p_igetw(&(m->tilewarpdmap[k]),f))
52640 {
52641 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52642 }
52643 }
52644
52645 for(int32_t k=0; k<4; k++)
52646 {
52647 if(!p_getc(&(m->tilewarpscr[k]),f))
52648 {
52649 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52650 }
52651 }
52652
52653 if(!p_getc(&(m->tilewarpoverlayflags),f))
52654 {
52655 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52656 }
52657
52658 if(!p_getc(&(m->exitdir),f))
52659 {
52660 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52661 }
52662
52663 for(int32_t k=0; k<10; k++)
52664 {
52665 {
52666 if(!p_igetw(&(m->enemy[k]),f))
52667 {
52668 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52669 }
52670 }
52671 }
52672
52673 if(!p_getc(&(m->pattern),f))
52674 {
52675 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52676 }
52677
52678 for(int32_t k=0; k<4; k++)
52679 {
52680 if(!p_getc(&(m->sidewarptype[k]),f))
52681 {
52682 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52683 }
52684 }
52685
52686 if(!p_getc(&(m->sidewarpoverlayflags),f))
52687 {
52688 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52689 }
52690
52691 if(!p_getc(&(m->warparrivalx),f))
52692 {
52693 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52694 }
52695
52696 if(!p_getc(&(m->warparrivaly),f))
52697 {
52698 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52699 }
52700
52701 for(int32_t k=0; k<4; k++)
52702 {
52703 if(!p_getc(&(m->path[k]),f))
52704 {
52705 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52706 }
52707 }
52708
52709 for(int32_t k=0; k<4; k++)
52710 {
52711 if(!p_getc(&(m->sidewarpscr[k]),f))
52712 {
52713 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52714 }
52715 }
52716
52717 for(int32_t k=0; k<4; k++)
52718 {
52719 if(!p_igetw(&(m->sidewarpdmap[k]),f))
52720 {
52721 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52722 }
52723 }
52724
52725 if(!p_getc(&(m->sidewarpindex),f))
52726 {
52727 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52728 }
52729
52730 if(!p_igetw(&(m->undercombo),f))
52731 {
52732 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52733 }
52734
52735 if(!p_getc(&(m->undercset),f))
52736 {
52737 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52738 }
52739
52740 if(!p_igetw(&(m->catchall),f))
52741 {
52742 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52743 }
52744
52745 if(!p_getc(&(m->flags),f))
52746 {
52747 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52748 }
52749
52750 if(!p_getc(&(m->flags2),f))
52751 {
52752 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52753 }
52754
52755 if(!p_getc(&(m->flags3),f))
52756 {
52757 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52758 }
52759
52760 if(!p_getc(&(m->flags4),f))
52761 {
52762 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52763 }
52764
52765 if(!p_getc(&(m->flags5),f))
52766 {
52767 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52768 }
52769
52770 if(!p_igetw(&(m->noreset),f))
52771 {
52772 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52773 }
52774
52775 if(!p_igetw(&(m->nocarry),f))
52776 {
52777 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52778 }
52779
52780 if(!p_getc(&(m->flags6),f))
52781 {
52782 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52783 }
52784
52785 if(!p_getc(&(m->flags7),f))
52786 {
52787 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52788 }
52789
52790 if(!p_getc(&(m->flags8),f))
52791 {
52792 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52793 }
52794
52795 if(!p_getc(&(m->flags9),f))
52796 {
52797 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52798 }
52799
52800 if(!p_getc(&(m->flags10),f))
52801 {
52802 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52803 }
52804
52805 if(!p_getc(&(m->csensitive),f))
52806 {
52807 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52808 }
52809
52810 if(!p_getc(&(m->oceansfx),f))
52811 {
52812 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52813 }
52814
52815 if(!p_getc(&(m->bosssfx),f))
52816 {
52817 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52818 }
52819
52820 if(!p_getc(&(m->secretsfx),f))
52821 {
52822 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52823 }
52824
52825 if(!p_getc(&(m->holdupsfx),f))
52826 {
52827 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52828 }
52829
52830 for(int32_t k=0; k<6; k++)
52831 {
52832 if(!p_getc(&(m->layermap[k]),f))
52833 {
52834 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52835 }
52836 }
52837
52838 for(int32_t k=0; k<6; k++)
52839 {
52840 if(!p_getc(&(m->layerscreen[k]),f))
52841 {
52842 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52843 }
52844 }
52845
52846 for(int32_t k=0; k<6; k++)
52847 {
52848 if(!p_getc(&(m->layeropacity[k]),f))
52849 {
52850 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52851 }
52852 }
52853
52854 if(!p_igetw(&(m->timedwarptics),f))
52855 {
52856 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52857 }
52858
52859 if(!p_getc(&(m->nextmap),f))
52860 {
52861 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52862 }
52863
52864 if(!p_getc(&(m->nextscr),f))
52865 {
52866 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52867 }
52868
52869 for(int32_t k=0; k<128; k++)
52870 {
52871 if(!p_igetw(&(m->secretcombo[k]),f))
52872 {
52873 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52874 }
52875 }
52876
52877 for(int32_t k=0; k<128; k++)
52878 {
52879 if(!p_getc(&(m->secretcset[k]),f))
52880 {
52881 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52882 }
52883 }
52884
52885 for(int32_t k=0; k<128; k++)
52886 {
52887 if(!p_getc(&(m->secretflag[k]),f))
52888 {
52889 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52890 }
52891 }
52892
52893 for(int32_t k=0; k<176; k++)
52894 {
52895 try
52896 {
52897 if(!p_igetw(&(m->data[k]),f))
52898 {
52899 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52900 }
52901 }
52902 catch(std::out_of_range& )
52903 {
52904 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52905 }
52906 }
52907
52908 for(int32_t k=0; k<176; k++)
52909 {
52910 try
52911 {
52912 if(!p_getc(&(m->sflag[k]),f))
52913 {
52914 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52915 }
52916 }
52917 catch(std::out_of_range& )
52918 {
52919 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52920 }
52921 }
52922
52923 for(int32_t k=0; k<176; k++)
52924 {
52925 try
52926 {
52927 if(!p_getc(&(m->cset[k]),f))
52928 {
52929 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52930 }
52931 }
52932 catch(std::out_of_range& )
52933 {
52934 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52935 }
52936 }
52937
52938 if(!p_igetw(&(m->screen_midi),f))
52939 {
52940 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52941 }
52942
52943 if(!p_getc(&(m->lens_layer),f))
52944 {
52945 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52946 }
52947 word tempw;
52948 for(int32_t k=0; k<32; k++)
52949 {
52950
52951 if(!p_igetw(&tempw,f))
52952 {
52953 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52954 }
52955 zc_ffc_set(m->ffcs[k], tempw);
52956
52957 if(!p_getc(&(m->ffcs[k].cset),f))
52958 {
52959 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52960 }
52961
52962 if(!p_igetw(&(m->ffcs[k].delay),f))
52963 {
52964 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52965 }
52966
52967 if(!p_igetzf(&(m->ffcs[k].x),f))
52968 {
52969 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52970 }
52971
52972 if(!p_igetzf(&(m->ffcs[k].y),f))
52973 {
52974 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52975 }
52976
52977 if(!p_igetzf(&(m->ffcs[k].vx),f))
52978 {
52979 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52980 }
52981
52982 if(!p_igetzf(&(m->ffcs[k].vy),f))
52983 {
52984 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52985 }
52986
52987 if(!p_igetzf(&(m->ffcs[k].ax),f))
52988 {
52989 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52990 }
52991
52992 if(!p_igetzf(&(m->ffcs[k].ay),f))
52993 {
52994 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52995 }
52996
52997 if(!p_getc(&(m->ffcs[k].link),f))
52998 {
52999 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53000 }
53001
53002 if(!p_igetl(&(m->ffcs[k].hit_width),f))
53003 {
53004 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53005 }
53006
53007 if(!p_igetl(&(m->ffcs[k].hit_height),f))
53008 {
53009 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53010 }
53011
53012 if(!p_getc(&(m->ffcs[k].txsz),f))
53013 {
53014 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53015 }
53016
53017 if(!p_getc(&(m->ffcs[k].tysz),f))
53018 {
53019 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53020 }
53021
53022 if(!p_igetl(&(m->ffcs[k].flags),f))
53023 {
53024 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53025 }
53026
53027 if(!p_igetw(&(m->ffcs[k].script),f))
53028 {
53029 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53030 }
53031
53032 if(!p_igetl(&(m->ffcs[k].initd[0]),f))
53033 {
53034 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53035 }
53036
53037 if(!p_igetl(&(m->ffcs[k].initd[1]),f))
53038 {
53039 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53040 }
53041
53042 if(!p_igetl(&(m->ffcs[k].initd[2]),f))
53043 {
53044 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53045 }
53046
53047 if(!p_igetl(&(m->ffcs[k].initd[3]),f))
53048 {
53049 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53050 }
53051
53052 if(!p_igetl(&(m->ffcs[k].initd[4]),f))
53053 {
53054 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53055 }
53056
53057 if(!p_igetl(&(m->ffcs[k].initd[5]),f))
53058 {
53059 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53060 }
53061
53062 if(!p_igetl(&(m->ffcs[k].initd[6]),f))
53063 {
53064 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53065 }
53066
53067 if(!p_igetl(&(m->ffcs[k].initd[7]),f))
53068 {
53069 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53070 }
53071
53072 }
53073
53074 for ( int32_t q = 0; q < 10; q++ )
53075 {
53076 if(!p_igetl(&(m->npcstrings[q]),f))
53077 {
53078 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53079 }
53080 }
53081 for ( int32_t q = 0; q < 10; q++ )
53082 {
53083 if(!p_igetw(&(m->new_items[q]),f))
53084 {
53085 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53086 }
53087 }
53088 for ( int32_t q = 0; q < 10; q++ )
53089 {
53090 if(!p_igetw(&(m->new_item_x[q]),f))
53091 {
53092 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53093 }
53094 }
53095 for ( int32_t q = 0; q < 10; q++ )
53096 {
53097 if(!p_igetw(&(m->new_item_y[q]),f))
53098 {
53099 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53100 }
53101 }
53102 if(!p_igetw(&(m->script),f))
53103 {
53104 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53105 }
53106 for ( int32_t q = 0; q < 8; q++ )
53107 {
53108 if(!p_igetl(&(m->screeninitd[q]),f))
53109 {
53110 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53111 }
53112
53113 }
53114 if(!p_getc(&(m->preloadscript),f))
53115 {
53116 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53117 }
53118
53119 if ( vers_id >= 2 )
53120 {
53121 if(!p_getc(&(m->hidelayers),f))
53122 {
53123 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53124 }
53125 if(!p_getc(&(m->hidescriptlayers),f))
53126 {
53127 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53128 }
53129
53130 }
53131
53132
53133 }//end mapscr all for loop
53134
53135 }
53136 }
53137 /*
53138 void FFScript::write_maps(PACKFILE *f, int32_t vers_id)
53139 {
53140 for(int32_t i=0; i<map_count && i<MAXMAPS; i++)
53141 {
53142 for(int32_t j=0; j<MAPSCRS; j++)
53143 {
53144 if ( !(FFCore.write_mapscreen(f,i,j,vers_id)) )
53145 {
53146 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODE: %d",i*j);
53147 }
53148 }
53149 }
53150 }
53151
53152 void FFScript::read_maps(PACKFILE *f, int32_t vers_id)
53153 {
53154 for(int32_t i=0; i<map_count && i<MAXMAPS; i++)
53155 {
53156 for(int32_t j=0; j<MAPSCRS; j++)
53157 {
53158 if ( !(FFCore.read_mapscreen(f,i,j,vers_id)) )
53159 {
53160 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE: %d",i*j);
53161 }
53162 }
53163 }
53164 }
53165 */
53166
53167
53168 int32_t FFScript::getHeroOTile(int32_t index1, int32_t index2)
53169 {
53170 {
53171 herospritetype lst = (herospritetype)index1;
53172 int32_t dir = index2;
53173 int32_t the_ret = 0;
53174 switch(lst)
53175 {
53176 case LSprwalkspr: the_ret = walkspr[dir][0]; break;
53177 case LSprstabspr: the_ret = stabspr[dir][0]; break;
53178 case LSprslashspr: the_ret = slashspr[dir][0]; break;
53179 case LSprrevslashspr: the_ret = revslashspr[dir][0]; break;
53180 case LSprfloatspr: the_ret = floatspr[dir][0]; break;
53181 case LSprswimspr: the_ret = swimspr[dir][0]; break;
53182 case LSprdivespr: the_ret = divespr[dir][0]; break;
53183 case LSprdrownspr: the_ret = drowningspr[dir][0]; break;
53184 case LSprsidedrownspr: the_ret = sidedrowningspr[dir][0]; break;
53185 case LSprlavadrownspr: the_ret = drowning_lavaspr[dir][0]; break;
53186 case LSprsideswimspr: the_ret = sideswimspr[dir][0]; break;
53187 case LSprsideswimslashspr: the_ret = sideswimslashspr[dir][0]; break;
53188 case LSprsideswimstabspr: the_ret = sideswimstabspr[dir][0]; break;
53189 case LSprsideswimpoundspr: the_ret = sideswimpoundspr[dir][0]; break;
53190 case LSprsideswimchargespr: the_ret = sideswimchargespr[dir][0]; break;
53191 case LSprpoundspr: the_ret = poundspr[dir][0]; break;
53192 case LSprjumpspr: the_ret = jumpspr[dir][0]; break;
53193 case LSprchargespr: the_ret = chargespr[dir][0]; break;
53194 case LSprcastingspr: the_ret = castingspr[0]; break;
53195 case LSprsideswimcastingspr: the_ret = sideswimcastingspr[0]; break;
53196 case LSprholdspr1: the_ret = holdspr[0][0][0]; break;
53197 case LSprholdspr2: the_ret = holdspr[0][1][0]; break;
53198 case LSprholdsprw1: the_ret = holdspr[1][0][0]; break;
53199 case LSprholdsprw2: the_ret = holdspr[1][1][0]; break;
53200 case LSprholdsprSw1: the_ret = sideswimholdspr[0][0]; break;
53201 case LSprholdsprSw2: the_ret = sideswimholdspr[1][0]; break;
53202 default: the_ret = 0;
53203 }
53204
53205 return the_ret*10000;
53206 }
53207 }
53208
53209 defWpnSprite FFScript::getDefWeaponSprite(int32_t wpnid)
53210 {
53211 switch(wpnid)
53212 {
53213 case wNone: return ws_0;
53214 case wSword: return ws_0;
53215 case wBeam: return wsBeam;
53216 case wBrang : return wsBrang;
53217 case wBomb: return wsBomb;
53218 case wSBomb: return wsSBomb;
53219 case wLitBomb: return wsBombblast;
53220 case wLitSBomb: return wsBombblast;
53221 case wArrow: return wsArrow;
53222 case wFire: return wsFire;
53223 case wWhistle: return wsUnused45;
53224 case wBait: return wsBait;
53225 case wWand: return wsWandHandle;
53226 case wMagic: return wsMagic;
53227 case wCatching: return wsUnused45;
53228 case wWind: return wsWind;
53229 case wRefMagic: return wsRefMagic;
53230 case wRefFireball: return wsRefFireball;
53231 case wRefRock: return wsRock;
53232 case wHammer: return wsHammer;
53233 case wHookshot: return wsHookshotHead;
53234 case wHSHandle: return wsHookshotHandle;
53235 case wHSChain: return wsHookshotChainH;
53236 case wSSparkle: return wsSilverSparkle;
53237 case wFSparkle: return wsGoldSparkle;
53238 case wSmack: return wsHammerSmack;
53239 case wPhantom: return wsUnused45;
53240 case wCByrna: return wsByrnaCane;
53241 case wRefBeam: return wsRefBeam;
53242 case wStomp: return wsUnused45;
53243 case lwMax: return wsUnused45;
53244 case wScript1:
53245 case wScript2:
53246 case wScript3:
53247 case wScript4:
53248 case wScript5:
53249 case wScript6:
53250 case wScript7:
53251 case wScript8:
53252 case wScript9:
53253 case wScript10: return ws_0;
53254 case wIce: return wsIce; //new
53255 case wFlame: return wsEFire2; //new
53256 //not implemented; t/b/a
53257 case wSound:
53258 case wThrown:
53259 case wPot:
53260 case wLit:
53261 case wBombos:
53262 case wEther:
53263 case wQuake:
53264 case wSword180:
53265 case wSwordLA: return wsUnused45;
53266
53267 case ewFireball: return wsFireball2;
53268 case ewArrow: return wsEArrow;
53269 case ewBrang: return wsBrang;
53270 case ewSword: return wsEBeam;
53271 case ewRock: return wsRock;
53272 case ewMagic: return wsEMagic;
53273 case ewBomb: return wsEBomb;
53274 case ewSBomb: return wsESbomb;
53275 case ewLitBomb: return wsEBombblast;
53276 case ewLitSBomb: return wsESbombblast;
53277 case ewFireTrail: return wsEFiretrail;
53278 case ewFlame: return wsEFire;
53279 case ewWind: return wsEWind;
53280 case ewFlame2: return wsEFire2;
53281 case ewFlame2Trail: return wsEFiretrail2;
53282 case ewIce: return wsIce;
53283 case ewFireball2: return wsFireball2;
53284 default: return wsUnused45;
53285 }
53286 };
53287
53288
53289 12 int32_t FFScript::getEnemyByScriptUID(int32_t sUID)
53290 {
53291
53292
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 for(word i = 0; i < guys.Count(); i++)
53293 {
53294 27 enemy *w = (enemy*)guys.spr(i);
53295
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 15 times.
27 if ( w ->script_UID == sUID ) return i;
53296 15 }
53297 return -1;
53298 12 }
53299
53300 598 int32_t FFScript::getLWeaponByScriptUID(int32_t sUID)
53301 {
53302
53303
1/2
✓ Branch 0 taken 2168 times.
✗ Branch 1 not taken.
2168 for(word i = 0; i < Lwpns.Count(); i++)
53304 {
53305 2168 weapon *w = (weapon*)Lwpns.spr(i);
53306
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 1570 times.
2168 if ( w ->script_UID == sUID ) return i;
53307 1570 }
53308 return -1;
53309 598 }
53310
53311 int32_t FFScript::getEWeaponByScriptUID(int32_t sUID)
53312 {
53313
53314 for(word i = 0; i < Ewpns.Count(); i++)
53315 {
53316 weapon *w = (weapon*)Ewpns.spr(i);
53317 if ( w ->script_UID == sUID ) return i;
53318 }
53319 return -1;
53320 }
53321
53322
53323 598 void FFScript::do_loadlweapon_by_script_uid(const bool v)
53324 {
53325 598 int32_t sUID = SH::get_arg(sarg1, v); //literal, not div by 10000
53326
53327 598 int32_t indx = FFCore.getLWeaponByScriptUID(sUID);
53328
1/2
✓ Branch 0 taken 598 times.
✗ Branch 1 not taken.
598 if ( indx > -1 )
53329 598 ri->lwpn = Lwpns.spr(indx)->getUID();
53330 else
53331 {
53332 ri->lwpn = 0;
53333 if(get_qr(qr_LOG_INVALID_UID_LOAD))
53334 Z_scripterrlog("There is no valid LWeapon associated with UID (%) at this time.\nThe UID is stale, or invalid.\n", sUID);
53335 }
53336 598 }
53337
53338 void FFScript::do_loadeweapon_by_script_uid(const bool v)
53339 {
53340
53341 int32_t sUID = SH::get_arg(sarg1, v); //literal, not div by 10000
53342
53343 int32_t indx = FFCore.getEWeaponByScriptUID(sUID);
53344 if ( indx > -1 )
53345 ri->ewpn = Ewpns.spr(indx)->getUID();
53346 else
53347 {
53348 ri->ewpn = 0;
53349 if(get_qr(qr_LOG_INVALID_UID_LOAD))
53350 Z_scripterrlog("There is no valid EWeapon associated with UID (%) at this time.\nThe UID is stale, or invalid.\n", sUID);
53351 }
53352 }
53353
53354
53355 12 void FFScript::do_loadnpc_by_script_uid(const bool v)
53356 {
53357
53358 12 int32_t sUID = SH::get_arg(sarg1, v); //literal, not div by 10000
53359
53360 12 int32_t indx = FFCore.getEnemyByScriptUID(sUID);
53361
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if ( indx > -1 )
53362 12 ri->guyref = guys.spr(indx)->getUID();
53363 else
53364 {
53365 ri->guyref = 0;
53366 if(get_qr(qr_LOG_INVALID_UID_LOAD))
53367 Z_scripterrlog("There is no valid NPC associated with UID (%) at this time.\nThe UID is stale, or invalid.\n", sUID);
53368 }
53369 12 }
53370
53371 //Combo Scripts
53372
53373 58862 void FFScript::clear_combo_scripts()
53374 {
53375 58862 memset(combo_id_cache, -1, sizeof(combo_id_cache));
53376 58862 clear_script_engine_data_of_type(ScriptType::Combo);
53377 58862 }
53378
53379 3018 void FFScript::clear_combo_script(int32_t lyr, int32_t pos)
53380 {
53381
1/2
✓ Branch 0 taken 3018 times.
✗ Branch 1 not taken.
3018 if(lyr < 0) return;
53382
53383
53384 3018 int32_t index = get_combopos_ref(pos, lyr);
53385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3018 times.
3018 if (index >= 176*7) return;
53386
53387 3018 combo_id_cache[index] = -1;
53388 3018 combopos_modified = index;
53389 3018 clear_script_engine_data(ScriptType::Combo, index);
53390 3018 }
53391
53392 int32_t FFScript::getComboDataLayer(int32_t c, ScriptType scripttype)
53393 {
53394 if ( scripttype != ScriptType::Combo )
53395 {
53396 Z_scripterrlog("combodata->Layer() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
53397 return -1;
53398 }
53399 else
53400 {
53401 int32_t l = 0;
53402 for (int32_t q = 176; q < 1232; q+= 176 )
53403 {
53404 if ( c < q )
53405 {
53406 return l;
53407 }
53408 ++l;
53409 }
53410 return -1;
53411 }
53412 }
53413
53414 int32_t FFScript::getCombodataPos(int32_t c, ScriptType scripttype)
53415 {
53416 if ( scripttype != ScriptType::Combo )
53417 {
53418 Z_scripterrlog("combodata->Pos() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
53419 return -1;
53420 }
53421 else return ((c%176));
53422 }
53423
53424 int32_t FFScript::getCombodataX(int32_t c, ScriptType scripttype)
53425 {
53426 if ( scripttype != ScriptType::Combo )
53427 {
53428 Z_scripterrlog("combodata->X() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
53429 return -1;
53430 }
53431 else
53432 {
53433 int32_t pos = getCombodataPos(c, scripttype);
53434 return COMBOX(pos);
53435 }
53436 }
53437
53438 int32_t FFScript::getCombodataY(int32_t c, ScriptType scripttype)
53439 {
53440 if ( scripttype != ScriptType::Combo )
53441 {
53442 Z_scripterrlog("combodata->Y() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
53443 return -1;
53444 }
53445 else
53446 {
53447 int32_t pos = getCombodataPos(c, scripttype);
53448 return COMBOY(pos);
53449 }
53450 }
53451
53452 void FFScript::ClearComboScripts()
53453 {
53454 for ( int32_t c = 0; c < 176; c++ )
53455 {
53456 reset_script_engine_data(ScriptType::Combo, c);
53457 }
53458 }
53459
53460 631293 int32_t FFScript::combo_script_engine(const bool preload, const bool waitdraw)
53461 {
53462 ///non-scripted effects
53463
2/2
✓ Branch 0 taken 4419051 times.
✓ Branch 1 taken 631293 times.
5050344 for ( int32_t q = 0; q < 7; ++q )
53464 {
53465
2/2
✓ Branch 0 taken 562569 times.
✓ Branch 1 taken 3856482 times.
4419051 if (!get_qr(qr_COMBOSCRIPTS_LAYER_0+q))
53466 3856482 continue;
53467
2/2
✓ Branch 0 taken 99012144 times.
✓ Branch 1 taken 562569 times.
99574713 for ( int32_t c = 0; c < 176; ++c )
53468 {
53469 // int32_t ls = (q ? tmpscr->layerscreen[q-1] : 0);
53470 // int32_t lm = (q ? tmpscr->layermap[q-1] : 0);
53471 // if(q && !lm) continue; //No layer for this screen
53472 99012144 int32_t idval = get_combopos_ref(c, q);
53473 99012144 mapscr* m = FFCore.tempScreens[q]; //get templayer mapscr for any layer (including 0)
53474 99012144 word cid = m->data[c];
53475
1/2
✓ Branch 0 taken 99012144 times.
✗ Branch 1 not taken.
99012144 if(combo_id_cache[idval] < 0)
53476 combo_id_cache[idval] = cid;
53477
2/2
✓ Branch 0 taken 98851249 times.
✓ Branch 1 taken 160895 times.
99012144 else if(combo_id_cache[idval] != cid)
53478 {
53479 160895 combopos_modified = idval;
53480 160895 combo_id_cache[idval] = cid;
53481 160895 clear_script_engine_data(ScriptType::Combo, idval);
53482 160895 }
53483
53484
2/2
✓ Branch 0 taken 98888376 times.
✓ Branch 1 taken 123768 times.
99012144 if ( combobuf[cid].script )
53485 {
53486 123768 auto& data = get_script_engine_data(ScriptType::Combo, idval);
53487
2/2
✓ Branch 0 taken 47615 times.
✓ Branch 1 taken 76153 times.
123768 if (data.doscript)
53488 {
53489
3/4
✓ Branch 0 taken 38064 times.
✓ Branch 1 taken 38089 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38064 times.
76153 if (waitdraw && !data.waitdraw) continue;
53490
53491 38089 ZScriptVersion::RunScript(ScriptType::Combo, combobuf[cid].script, idval);
53492
1/2
✓ Branch 0 taken 38089 times.
✗ Branch 1 not taken.
38089 if (waitdraw) data.waitdraw = false;
53493 38089 }
53494 85704 }
53495 98974080 }
53496 562569 }
53497 631293 return 1;
53498 }
53499
53500 //Config for file->
53501
53502 /* ______ ___ ___
53503 * /\ _ \ /\_ \ /\_ \
53504 * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
53505 * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
53506 * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
53507 * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
53508 * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
53509 * /\____/
53510 * \_/__/
53511 *
53512 * Ported from Allegro 4.4.3.1 Configuration routines.
53513 *
53514 * By Shawn Hargreaves; C++ Port by ZoriaRPG
53515 *
53516 * Hook functions added by Martijn Versteegh.
53517 *
53518 * Annie Testes lifted several hardcoded length limitations.
53519 *
53520 * See readme.txt for copyright information.
53521 */
53522
53523
53524 #include "allegro.h"
53525 #include "allegro/internal/aintern.h"
53526
53527
53528
53529
53530
53531 /* zscript_flush_config:
53532 * Writes out a config structure to disk if the contents
53533 * have changed.
53534 */
53535 void zscript_flush_config(ZSCRIPT_CONFIG *cfg)
53536 {
53537 ZSCRIPT_CONFIG_ENTRY *pos;
53538 PACKFILE *f;
53539 char cr[16];
53540
53541 usetc(cr+usetc(cr, '\n'), 0);
53542
53543 if (cfg && cfg->filename && cfg->dirty)
53544 {
53545 /* write changed data to disk */
53546 f = pack_fopen(cfg->filename, F_WRITE);
53547
53548 if (f)
53549 {
53550 pos = cfg->head;
53551
53552 while (pos)
53553 {
53554 if (pos->name)
53555 {
53556 pack_fputs(pos->name, f);
53557
53558 if (ugetc(pos->name) != '[')
53559 {
53560 pack_putc(' ', f);
53561 pack_putc('=', f);
53562 pack_putc(' ', f);
53563 }
53564 }
53565
53566 if (pos->data)
53567 pack_fputs(pos->data, f);
53568
53569 pack_fputs(cr, f);
53570
53571 pos = pos->next;
53572 }
53573
53574 pack_fclose(f);
53575 cfg->dirty = FALSE;
53576 }
53577 }
53578 }
53579
53580
53581
53582 /* zscript_flush_config_file:
53583 * Writes out the config file to disk if the contents
53584 * have changed.
53585 */
53586 void zscript_flush_config_file(void)
53587 {
53588 zscript_flush_config(config[0]);
53589 }
53590
53591
53592
53593 /* zscript_destroy_config:
53594 * Destroys a config structure, writing it out to disk if the contents
53595 * have changed.
53596 */
53597 void zscript_destroy_config(ZSCRIPT_CONFIG *cfg)
53598 {
53599 ZSCRIPT_CONFIG_ENTRY *pos, *prev;
53600
53601 if (cfg)
53602 {
53603 zscript_flush_config(cfg);
53604
53605 if (cfg->filename)
53606 _AL_FREE(cfg->filename);
53607
53608 /* destroy the variable list */
53609 pos = cfg->head;
53610
53611 while (pos)
53612 {
53613 prev = pos;
53614 pos = pos->next;
53615
53616 if (prev->name)
53617 _AL_FREE(prev->name);
53618
53619 if (prev->data)
53620 _AL_FREE(prev->data);
53621
53622 _AL_FREE(prev);
53623 }
53624
53625 _AL_FREE(cfg);
53626 }
53627 }
53628
53629
53630
53631 /* zscript_config_cleanup:
53632 * Called at shutdown time to free memory being used by the config routines,
53633 * and write any changed data out to disk.
53634 */
53635 void zscript_config_cleanup(void)
53636 {
53637 ZSCRIPT_CONFIG_HOOK *hook, *nexthook;
53638 int32_t i;
53639
53640 for (i=0; i<MAX_CONFIGS; i++)
53641 {
53642 if (config[i])
53643 {
53644 zscript_destroy_config(config[i]);
53645 config[i] = NULL;
53646 }
53647 }
53648
53649 if (config_override)
53650 {
53651 zscript_destroy_config(config_override);
53652 config_override = NULL;
53653 }
53654
53655 if (config_language)
53656 {
53657 zscript_destroy_config(config_language);
53658 config_language = NULL;
53659 }
53660
53661 if (system_config)
53662 {
53663 zscript_destroy_config(system_config);
53664 system_config = NULL;
53665 }
53666
53667 if (config_hook)
53668 {
53669 hook = config_hook;
53670
53671 while (hook)
53672 {
53673 if (hook->section)
53674 _AL_FREE(hook->section);
53675
53676 nexthook = hook->next;
53677 _AL_FREE(hook);
53678 hook = nexthook;
53679 }
53680
53681 config_hook = NULL;
53682 }
53683
53684 _AL_FREE(config_argv);
53685 config_argv = NULL;
53686
53687 _AL_FREE(argv_buf);
53688 argv_buf = NULL;
53689
53690 argv_buf_size = 0;
53691
53692 _remove_exit_func(zscript_config_cleanup);
53693 config_installed = FALSE;
53694 }
53695
53696
53697
53698 /* zscript_init_config:
53699 * Sets up the configuration routines ready for use, also loading the
53700 * default config file if the loaddata flag is set and no other config
53701 * file is in memory.
53702 */
53703 void zscript_init_config(int32_t loaddata)
53704 {
53705 char filename[1024], tmp[128], *cfg_name;
53706
53707 if (!config_installed)
53708 {
53709 _add_exit_func(zscript_config_cleanup, "zscript_config_cleanup");
53710 config_installed = TRUE;
53711 }
53712
53713 if ((loaddata) && (!config[0]))
53714 {
53715 cfg_name = uconvert_ascii("allegro.cfg", tmp);
53716
53717 if (find_allegro_resource(filename, cfg_name, NULL, NULL, NULL, NULL, NULL, sizeof(filename)) != 0)
53718 {
53719 get_executable_name(filename, sizeof(filename));
53720 usetc(get_filename(filename), 0);
53721 ustrzcat(filename, sizeof(filename), cfg_name);
53722 }
53723
53724 zscript_set_config_file(filename);
53725 }
53726
53727 if (!system_config)
53728 {
53729 system_config = (struct ZSCRIPT_CONFIG*)malloc(sizeof(ZSCRIPT_CONFIG));
53730 if (system_config)
53731 {
53732 system_config->head = NULL;
53733 system_config->filename = NULL;
53734 system_config->dirty = FALSE;
53735 }
53736 }
53737 }
53738
53739
53740
53741 /* zscript_get_config_line:
53742 * Helper for splitting files up into individual lines. Returns the length
53743 * in bytes of the sequence of characters delimited by the first EOL marker
53744 * in the array DATA of length LENGTH, and allocates NAME and VAL to record
53745 * the name and the value of the config entry respectively; otherwise set
53746 * NAME to NULL and returns a copy of the line through VAL if the line was
53747 * blank or a comment. Returns -1 and set allegro_errno on failure.
53748 */
53749 int32_t zscript_get_config_line(const char *data, int32_t length, char **name, char **val)
53750 {
53751 char *buf;
53752 int32_t buf_size=256;
53753 int32_t inpos, outpos, i, j;
53754 int32_t c, c2, w0;
53755
53756 inpos = 0;
53757 outpos = 0;
53758 w0 = ucwidth(0);
53759
53760 buf = (char*)_AL_MALLOC_ATOMIC(buf_size);
53761 if (!buf)
53762 {
53763 *allegro_errno = ENOMEM;
53764 return -1;
53765 }
53766
53767 /* search for an EOL marker */
53768 while (inpos<length)
53769 {
53770 c = ugetc(data+inpos);
53771 if ((c == '\r') || (c == '\n'))
53772 {
53773 inpos += uwidth(data+inpos);
53774 if (inpos < length)
53775 {
53776 c2 = ugetc(data+inpos);
53777 if (((c == '\r') && (c2 == '\n')) || ((c == '\n') && (c2 == '\r')))
53778 inpos += uwidth(data+inpos);
53779 }
53780 break;
53781 }
53782
53783 /* increase the buffer size if needed */
53784 if (outpos>=(int32_t)buf_size-w0)
53785 {
53786 buf_size *= 2;
53787 buf = (char*)_al_sane_realloc(buf, buf_size);
53788 if (!buf)
53789 {
53790 *allegro_errno = ENOMEM;
53791 return -1;
53792 }
53793 }
53794
53795 outpos += usetc(buf+outpos, c);
53796 inpos += uwidth(data+inpos);
53797 }
53798
53799 usetc(buf+outpos, 0);
53800
53801 /* skip leading spaces */
53802 i = 0;
53803 c = ugetc(buf);
53804
53805 while ((c) && (uisspace(c)))
53806 {
53807 i += uwidth(buf+i);
53808 c = ugetc(buf+i);
53809 }
53810
53811 /* read name string */
53812 j = 0;
53813
53814 /* compute name length */
53815 while ((c) && (!uisspace(c)) && (c != '=') && (c != '#'))
53816 {
53817 j += ucwidth(c);
53818 i += uwidth(buf+i);
53819 c = ugetc(buf+i);
53820 }
53821
53822 if (j)
53823 {
53824 /* got a variable */
53825 *name = (char*)_AL_MALLOC_ATOMIC(j+w0);
53826 if (!(*name))
53827 {
53828 *allegro_errno = ENOMEM;
53829 _AL_FREE(buf);
53830 return -1;
53831 }
53832
53833 ustrzcpy(*name, j+w0, buf+i-j);
53834
53835 while ((c) && ((uisspace(c)) || (c == '=')))
53836 {
53837 i += uwidth(buf+i);
53838 c = ugetc(buf+i);
53839 }
53840
53841 *val = _al_ustrdup(buf+i);
53842 if (!(*val))
53843 {
53844 _AL_FREE(name);
53845 _AL_FREE(buf);
53846 return -1;
53847 }
53848
53849 /* strip trailing spaces */
53850 i = ustrlen(*val) - 1;
53851 while ((i >= 0) && (uisspace(ugetat(*val, i))))
53852 usetat(*val, i--, 0);
53853 }
53854 else
53855 {
53856 /* blank line or comment */
53857 *name = NULL;
53858 *val = _al_ustrdup(buf);
53859 if (!(*val))
53860 {
53861 _AL_FREE(buf);
53862 return -1;
53863 }
53864 }
53865
53866 _AL_FREE(buf);
53867
53868 return inpos;
53869 }
53870
53871
53872
53873 /* zscript_set_config:
53874 * Does the work of setting up a config structure.
53875 */
53876 void zscript_set_config(ZSCRIPT_CONFIG **config, const char *data, int32_t length, const char *filename)
53877 {
53878 ZSCRIPT_CONFIG_ENTRY **prev, *p;
53879 char *name, *val;
53880 int32_t ret, pos;
53881
53882 zscript_init_config(FALSE);
53883
53884 if (*config)
53885 {
53886 zscript_destroy_config(*config);
53887 *config = NULL;
53888 }
53889
53890 *config = (struct ZSCRIPT_CONFIG*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG));
53891 if (!(*config))
53892 {
53893 *allegro_errno = ENOMEM;
53894 return;
53895 }
53896
53897 (*config)->head = NULL;
53898 (*config)->dirty = FALSE;
53899
53900 if (filename)
53901 {
53902 (*config)->filename = _al_ustrdup(filename);
53903 if (!(*config)->filename)
53904 {
53905 _AL_FREE(*config);
53906 *config = NULL;
53907 return;
53908 }
53909 }
53910 else
53911 (*config)->filename = NULL;
53912
53913 prev = &(*config)->head;
53914 pos = 0;
53915
53916 while (pos < length)
53917 {
53918 ret = zscript_get_config_line(data+pos, length-pos, &name, &val);
53919 if (ret<0)
53920 {
53921 _AL_FREE(*config);
53922 *config = NULL;
53923 return;
53924 }
53925
53926 pos += ret;
53927
53928 p = (struct ZSCRIPT_CONFIG_ENTRY*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG_ENTRY));
53929 if (!p)
53930 {
53931 *allegro_errno = ENOMEM;
53932 _AL_FREE(*config);
53933 *config = NULL;
53934 return;
53935 }
53936
53937 p->name = name;
53938 p->data = val;
53939
53940 p->next = NULL;
53941 *prev = p;
53942 prev = &p->next;
53943 }
53944 }
53945
53946
53947
53948 /* zscript_load_config_file:
53949 * Does the work of loading a config file.
53950 */
53951 void zscript_load_config_file(ZSCRIPT_CONFIG **config, const char *filename, const char *savefile)
53952 {
53953 char *tmp, *tmp2;
53954 uint64_t length;
53955
53956 if (*config)
53957 {
53958 zscript_destroy_config(*config);
53959 *config = NULL;
53960 }
53961
53962 /* Special case when allegro_init has not been called yet. */
53963 if (!system_driver)
53964 {
53965 zscript_set_config(config, NULL, 0, savefile);
53966 return;
53967 }
53968
53969 length = file_size_ex(filename);
53970
53971 if (length > 0)
53972 {
53973 PACKFILE *f = pack_fopen(filename, F_READ);
53974
53975 if (f)
53976 {
53977 tmp = (char*)_AL_MALLOC_ATOMIC(length+1);
53978
53979 if (tmp)
53980 {
53981 pack_fread(tmp, length, f);
53982 tmp[length] = 0;
53983
53984 if (need_uconvert(tmp, U_UTF8, U_CURRENT))
53985 {
53986 length = uconvert_size(tmp, U_UTF8, U_CURRENT);
53987 tmp2 = (char*)_AL_MALLOC_ATOMIC(length);
53988
53989 if (tmp2)
53990 do_uconvert(tmp, U_UTF8, tmp2, U_CURRENT, length);
53991
53992 length -= ucwidth(0);
53993 }
53994 else
53995 tmp2 = tmp;
53996
53997 if (tmp2)
53998 {
53999 zscript_set_config(config, tmp2, length, savefile);
54000
54001 if (tmp2 != tmp)
54002 _AL_FREE(tmp2);
54003 }
54004
54005 _AL_FREE(tmp);
54006 }
54007 else
54008 zscript_set_config(config, NULL, 0, savefile);
54009
54010 pack_fclose(f);
54011 }
54012 else
54013 zscript_set_config(config, NULL, 0, savefile);
54014 }
54015 else
54016 zscript_set_config(config, NULL, 0, savefile);
54017 }
54018
54019
54020
54021 /* zscript_set_config_file:
54022 * Sets the file to be used for all future configuration operations.
54023 */
54024 void zscript_set_config_file(const char *filename)
54025 {
54026 ASSERT(filename);
54027 zscript_load_config_file(&config[0], filename, filename);
54028 }
54029
54030
54031
54032 /* zscript_set_config_data:
54033 * Sets the block of data to be used for all future configuration
54034 * operations.
54035 */
54036 void zscript_set_config_data(const char *data, int32_t length)
54037 {
54038 ASSERT(data);
54039 zscript_set_config(&config[0], data, length, NULL);
54040 }
54041
54042
54043
54044 /* zscript_override_config_file:
54045 * Sets the file that will override all future configuration operations.
54046 */
54047 void zscript_override_config_file(const char *filename)
54048 {
54049 /* load other configuration file to override settings */
54050 if (filename)
54051 zscript_load_config_file(&config_override, filename, filename);
54052 /* destroy the current one */
54053 else if (config_override)
54054 {
54055 zscript_destroy_config(config_override);
54056 config_override = NULL;
54057 }
54058 }
54059
54060
54061
54062 /* zscript_override_config_data:
54063 * Sets the block of data that will override all future configuration
54064 * operations.
54065 */
54066 void zscript_override_config_data(const char *data, int32_t length)
54067 {
54068 ASSERT(data);
54069 zscript_set_config(&config_override, data, length, NULL);
54070 }
54071
54072
54073
54074 /* zscript_push_config_state:
54075 * Pushes the current config state onto the stack.
54076 */
54077 void zscript_push_config_state(void)
54078 {
54079 int32_t i;
54080
54081 if (config[MAX_CONFIGS-1])
54082 zscript_destroy_config(config[MAX_CONFIGS-1]);
54083
54084 for (i=MAX_CONFIGS-1; i>0; i--)
54085 config[i] = config[i-1];
54086
54087 config[0] = NULL;
54088 }
54089
54090
54091
54092 /* zscript_pop_config_state:
54093 * Pops the current config state off the stack.
54094 */
54095 void zscript_pop_config_state(void)
54096 {
54097 int32_t i;
54098
54099 if (config[0])
54100 zscript_destroy_config(config[0]);
54101
54102 for (i=0; i<MAX_CONFIGS-1; i++)
54103 config[i] = config[i+1];
54104
54105 config[MAX_CONFIGS-1] = NULL;
54106 }
54107
54108
54109
54110 /* zscript_prettify_config_section_name:
54111 * Helper for ensuring that a section name is enclosed by [ ] braces.
54112 */
54113 void zscript_prettify_config_section_name(const char *in, char *out, int32_t out_size)
54114 {
54115 int32_t p;
54116
54117 if ((in) && (ustrlen(in)))
54118 {
54119 if (ugetc(in) != '[')
54120 {
54121 p = usetc(out, '[');
54122 usetc(out+p, 0);
54123 }
54124 else
54125 usetc(out, 0);
54126
54127 ustrzcat(out, out_size - ucwidth(']'), in);
54128
54129 out += uoffset(out, -1);
54130
54131 if (ugetc(out) != ']')
54132 {
54133 out += uwidth(out);
54134 out += usetc(out, ']');
54135 usetc(out, 0);
54136 }
54137 }
54138 else
54139 usetc(out, 0);
54140 }
54141
54142
54143
54144 /* zscript_hook_config_section:
54145 * Hooks a config section to a set of getter/setter functions. This will
54146 * override the normal table of values, and give the provider of the hooks
54147 * complete control over that section.
54148 */
54149 void zscript_hook_config_section(const char *section, int32_t (*intgetter)(const char *, int32_t), const char *(*stringgetter)(const char *, const char *), void (*stringsetter)(const char *, const char *))
54150 {
54151 ZSCRIPT_CONFIG_HOOK *hook, **prev;
54152 char section_name[256];
54153
54154 zscript_init_config(FALSE);
54155
54156 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
54157
54158 hook = config_hook;
54159 prev = &config_hook;
54160
54161 while (hook)
54162 {
54163 if (ustricmp(section_name, hook->section) == 0)
54164 {
54165 if ((intgetter) || (stringgetter) || (stringsetter))
54166 {
54167 /* modify existing hook */
54168 hook->intgetter = intgetter;
54169 hook->stringgetter = stringgetter;
54170 hook->stringsetter = stringsetter;
54171 }
54172 else
54173 {
54174 /* remove a hook */
54175 *prev = hook->next;
54176 _AL_FREE(hook->section);
54177 }
54178
54179 return;
54180 }
54181
54182 prev = &hook->next;
54183 hook = hook->next;
54184 }
54185
54186 /* add a new hook */
54187 hook = (struct ZSCRIPT_CONFIG_HOOK*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG_HOOK));
54188 if (!hook)
54189 return;
54190
54191 hook->section = _al_ustrdup(section_name);
54192 if (!(hook->section))
54193 {
54194 _AL_FREE(hook);
54195 return;
54196 }
54197
54198 hook->intgetter = intgetter;
54199 hook->stringgetter = stringgetter;
54200 hook->stringsetter = stringsetter;
54201
54202 hook->next = config_hook;
54203 config_hook = hook;
54204 }
54205
54206
54207
54208 /* is_config_hooked:
54209 * Checks whether a specific section is hooked in any way.
54210 */
54211 int32_t zscript_config_is_hooked(const char *section)
54212 {
54213 ZSCRIPT_CONFIG_HOOK *hook = config_hook;
54214 char section_name[256];
54215
54216 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
54217
54218 while (hook)
54219 {
54220 if (ustricmp(section_name, hook->section) == 0)
54221 return TRUE;
54222
54223 hook = hook->next;
54224 }
54225
54226 return FALSE;
54227 }
54228
54229
54230
54231 /* zscript_find_config_string:
54232 * Helper for finding an entry in the configuration file.
54233 */
54234 ZSCRIPT_CONFIG_ENTRY *zscript_find_config_string(ZSCRIPT_CONFIG *config, const char *section, const char *name, ZSCRIPT_CONFIG_ENTRY **prev)
54235 {
54236 ZSCRIPT_CONFIG_ENTRY *p;
54237 int32_t in_section;
54238
54239 if (config)
54240 {
54241 p = config->head;
54242
54243 if (prev)
54244 *prev = NULL;
54245
54246 if (section && ugetc(section))
54247 in_section = FALSE;
54248 else
54249 in_section = TRUE;
54250
54251 while (p)
54252 {
54253 if (p->name)
54254 {
54255 if ((section) && (ugetc(p->name) == '[') && (ugetat(p->name, -1) == ']'))
54256 {
54257 /* change section */
54258 in_section = (ustricmp(section, p->name) == 0);
54259 }
54260 if ((in_section) || (ugetc(name) == '['))
54261 {
54262 /* is this the one? */
54263 if (ustricmp(p->name, name) == 0)
54264 return p;
54265 }
54266 }
54267
54268 if (prev)
54269 *prev = p;
54270
54271 p = p->next;
54272 }
54273 }
54274
54275 return NULL;
54276 }
54277
54278
54279
54280 /* zscript_get_config_string:
54281 * Reads a string from the configuration file.
54282 */
54283 const char *zscript_get_config_string(const char *section, const char *name, const char *def)
54284 {
54285 char section_name[256];
54286 ZSCRIPT_CONFIG_HOOK *hook;
54287 ZSCRIPT_CONFIG_ENTRY *p;
54288
54289 zscript_init_config(TRUE);
54290
54291 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
54292
54293 /* check for hooked sections */
54294 hook = config_hook;
54295
54296 while (hook)
54297 {
54298 if (ustricmp(section_name, hook->section) == 0)
54299 {
54300 if (hook->stringgetter)
54301 return hook->stringgetter(name, def);
54302 else
54303 return def;
54304 }
54305 hook = hook->next;
54306 }
54307
54308 /* find the string */
54309 p = zscript_find_config_string(config_override, section_name, name, NULL);
54310
54311 if (!p)
54312 {
54313 if ((ugetc(name) == '#') || ((ugetc(section_name) == '[') && (ugetat(section_name, 1) == '#')))
54314 p = zscript_find_config_string(system_config, section_name, name, NULL);
54315 else
54316 p = zscript_find_config_string(config[0], section_name, name, NULL);
54317 }
54318
54319 if (p && p->data && (ustrlen(p->data) != 0))
54320 return p->data;
54321 else
54322 return def;
54323 }
54324
54325
54326
54327 /* zscript_get_config_int:
54328 * Reads an integer from the configuration file.
54329 */
54330 int32_t zscript_get_config_int(const char *section, const char *name, int32_t def)
54331 {
54332 ZSCRIPT_CONFIG_HOOK *hook;
54333 char section_name[256];
54334 const char *s;
54335
54336 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
54337
54338 /* check for hooked sections */
54339 hook = config_hook;
54340
54341 while (hook)
54342 {
54343 if (ustricmp(section_name, hook->section) == 0)
54344 {
54345 if (hook->intgetter)
54346 {
54347 return hook->intgetter(name, def);
54348 }
54349 else if (hook->stringgetter)
54350 {
54351 s = hook->stringgetter(name, NULL);
54352 if ((s) && (ugetc(s)))
54353 return ustrtol(s, NULL, 0);
54354 else
54355 return def;
54356 }
54357 else
54358 return def;
54359 }
54360 hook = hook->next;
54361 }
54362
54363 /* read normal data */
54364 s = zscript_get_config_string(section_name, name, NULL);
54365
54366 if ((s) && (ugetc(s)))
54367 return ustrtol(s, NULL, 0);
54368
54369 return def;
54370 }
54371
54372
54373
54374 /* zscript_get_config_hex:
54375 * Reads a hexadecimal integer from the configuration file.
54376 */
54377 int32_t zscript_get_config_hex(const char *section, const char *name, int32_t def)
54378 {
54379 const char *s = zscript_get_config_string(section, name, NULL);
54380 char tmp[64];
54381 int32_t i;
54382
54383 if ((s) && (ugetc(s)))
54384 {
54385 i = ustrtol(s, NULL, 16);
54386 if ((i == 0x7FFFFFFF) && (ustricmp(s, uconvert_ascii("7FFFFFFF", tmp)) != 0))
54387 i = -1;
54388 return i;
54389 }
54390
54391 return def;
54392 }
54393
54394
54395
54396 /* zscript_get_config_float:
54397 * Reads a float from the configuration file.
54398 */
54399 float zscript_get_config_float(const char *section, const char *name, float def)
54400 {
54401 const char* s = zscript_get_config_string(section, name, NULL);
54402
54403 if ((s) && (ugetc(s)))
54404 return uatof(s);
54405
54406 return def;
54407 }
54408
54409
54410
54411 /* zscript_get_config_id:
54412 * Reads a driver ID number from the configuration file.
54413 */
54414 int32_t zscript_get_config_id(const char *section, const char *name, int32_t def)
54415 {
54416 const char *s = zscript_get_config_string(section, name, NULL);
54417 char tmp[4];
54418 char* endp;
54419 int32_t val, i;
54420
54421 if ((s) && (ugetc(s)))
54422 {
54423 val = ustrtol(s, &endp, 0);
54424 if (!ugetc(endp))
54425 return val;
54426
54427 tmp[0] = tmp[1] = tmp[2] = tmp[3] = ' ';
54428
54429 for (i=0; i<4; i++)
54430 {
54431 if (ugetat(s, i))
54432 tmp[i] = utoupper(ugetat(s ,i));
54433 else
54434 break;
54435 }
54436
54437 return AL_ID(tmp[0], tmp[1], tmp[2], tmp[3]);
54438 }
54439
54440 return def;
54441 }
54442
54443
54444
54445 /* zscript_get_config_argv:
54446 * Reads an argc/argv style token list from the configuration file.
54447 */
54448 char **zscript_get_config_argv(const char *section, const char *name, int32_t *argc)
54449 {
54450 int32_t pos, ac, q, c;
54451 int32_t s_size;
54452 int32_t i;
54453
54454 const char *s = zscript_get_config_string(section, name, NULL);
54455
54456 if (!s)
54457 {
54458 *argc = 0;
54459 return NULL;
54460 }
54461
54462 /* clean up the old argv that was allocated the last time this function was
54463 * called.
54464 */
54465 _AL_FREE(config_argv);
54466 config_argv = NULL;
54467
54468 /* increase the buffer size if needed */
54469 s_size = ustrsizez(s);
54470 if (s_size>argv_buf_size)
54471 {
54472 argv_buf_size = s_size;
54473 argv_buf = (char*)_al_sane_realloc(argv_buf, argv_buf_size);
54474 if (!argv_buf)
54475 {
54476 *allegro_errno = ENOMEM;
54477 *argc = 0;
54478 return NULL;
54479 }
54480 }
54481
54482 ustrzcpy(argv_buf, argv_buf_size, s);
54483 pos = 0;
54484 ac = 0;
54485
54486 /* tokenize the buffer and count the number of words; every space character
54487 * as well as single and double quotes are replaced with zeros; comments * that start with # are also cut off with a 0
54488 */
54489 c = ugetc(argv_buf);
54490 while ((c) && (c != '#'))
54491 {
54492 /* replace all spaces up to the next word with 0 */
54493 while ((c) && (uisspace(c)))
54494 {
54495 usetat(argv_buf+pos, 0, 0);
54496 pos += ucwidth(0);
54497 c = ugetc(argv_buf+pos);
54498 }
54499
54500 /* quit if we reached the end of the buffer or a comment */
54501 if ((c) && (c != '#'))
54502 {
54503 /* found another word! */
54504 ac++;
54505
54506 /* cut away quotes by replacing them with 0 */
54507 if ((c == '\'') || (c == '"'))
54508 {
54509 q = c;
54510 usetat(argv_buf+pos, 0, 0);
54511 pos += ucwidth(0);
54512 c = ugetc(argv_buf+pos);
54513 }
54514 else
54515 {
54516 q = 0;
54517 }
54518
54519 /* search for the end of the word */
54520 while ((c) && ((q) ? (c != q) : (!uisspace(c))))
54521 {
54522 pos += ucwidth(c);
54523 c = ugetc(argv_buf+pos);
54524 }
54525 }
54526 }
54527
54528 /* now that we know how many words there are in the buffer, allocate enough
54529 * space for a list of pointers to them, or return 0 if there are no words
54530 */
54531 if (ac > 0)
54532 {
54533 config_argv = (char**)_AL_MALLOC(ac*sizeof *config_argv);
54534 }
54535 else
54536 {
54537 *argc = 0;
54538 return NULL;
54539 }
54540
54541 /* go through the tokenized buffer and assign pointers in argv to point to
54542 * the beginning of each individual word
54543 */
54544 for (i=0,pos=0,c=ugetc(argv_buf); i<ac; i++)
54545 {
54546 /* find next word */
54547 while (!c)
54548 {
54549 pos += ucwidth(c);
54550 c = ugetc(argv_buf+pos);
54551 }
54552
54553 /* assign pointer */
54554 config_argv[i] = argv_buf+pos;
54555
54556 /* find end of the word */
54557 while (c)
54558 {
54559 pos += ucwidth(c);
54560 c = ugetc(argv_buf+pos);
54561 }
54562 }
54563
54564 *argc = ac;
54565 return config_argv;
54566 }
54567
54568
54569
54570 /* zscript_insert_config_variable:
54571 * Helper for inserting a new variable into a configuration file.
54572 */
54573 ZSCRIPT_CONFIG_ENTRY *zscript_insert_config_variable(ZSCRIPT_CONFIG *the_config, ZSCRIPT_CONFIG_ENTRY *p, const char *name, const char *data)
54574 {
54575 ZSCRIPT_CONFIG_ENTRY *n = (struct ZSCRIPT_CONFIG_ENTRY*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG_ENTRY));
54576
54577 if (!n)
54578 return NULL;
54579
54580 if (name)
54581 n->name = _al_ustrdup(name);
54582 else
54583 n->name = NULL;
54584
54585 if (data)
54586 n->data = _al_ustrdup(data);
54587 else
54588 n->data = NULL;
54589
54590 if (p)
54591 {
54592 n->next = p->next;
54593 p->next = n;
54594 }
54595 else
54596 {
54597 n->next = NULL;
54598 the_config->head = n;
54599 }
54600
54601 return n;
54602 }
54603
54604
54605
54606 /* zscript_set_config_string:
54607 * Writes a string to the configuration file.
54608 */
54609 void zscript_set_config_string(const char *section, const char *name, const char *val)
54610 {
54611 ZSCRIPT_CONFIG *the_config;
54612 ZSCRIPT_CONFIG_HOOK *hook;
54613 ZSCRIPT_CONFIG_ENTRY *p, *prev;
54614 char section_name[256];
54615
54616 zscript_init_config(TRUE);
54617
54618 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
54619
54620 /* check for hooked sections */
54621 hook = config_hook;
54622
54623 while (hook)
54624 {
54625 if (ustricmp(section_name, hook->section) == 0)
54626 {
54627 if (hook->stringsetter)
54628 hook->stringsetter(name, val);
54629 return;
54630 }
54631 hook = hook->next;
54632 }
54633
54634 /* decide which config file to use */
54635 if ((ugetc(name) == '#') || ((ugetc(section_name) == '[') && (ugetat(section_name, 1) == '#')))
54636 the_config = system_config;
54637 else if (config_override)
54638 the_config = config_override;
54639 else
54640 the_config = config[0];
54641
54642 if (the_config)
54643 {
54644 p = zscript_find_config_string(the_config, section_name, name, &prev);
54645
54646 if (p)
54647 {
54648 if ((val) && (ugetc(val)))
54649 {
54650 /* modify existing variable */
54651 if (p->data)
54652 _AL_FREE(p->data);
54653
54654 p->data = _al_ustrdup(val);
54655 }
54656 else
54657 {
54658 /* delete variable */
54659 if (p->name)
54660 _AL_FREE(p->name);
54661
54662 if (p->data)
54663 _AL_FREE(p->data);
54664
54665 if (prev)
54666 prev->next = p->next;
54667 else
54668 the_config->head = p->next;
54669
54670 _AL_FREE(p);
54671 }
54672 }
54673 else
54674 {
54675 if ((val) && (ugetc(val)))
54676 {
54677 /* add a new variable */
54678 if (ugetc(section_name))
54679 {
54680 p = zscript_find_config_string(the_config, NULL, section_name, &prev);
54681
54682 if (!p)
54683 {
54684 /* create a new section */
54685 p = the_config->head;
54686 while ((p) && (p->next))
54687 p = p->next;
54688
54689 if ((p) && (p->data) && (ugetc(p->data)))
54690 p = zscript_insert_config_variable(the_config, p, NULL, NULL);
54691
54692 p = zscript_insert_config_variable(the_config, p, section_name, NULL);
54693 }
54694
54695 /* append to the end of the section */
54696 while ((p) && (p->next) &&
54697 (((p->next->name) && (ugetc(p->next->name))) ||
54698 ((p->next->data) && (ugetc(p->next->data)))))
54699 {
54700 p = p->next;
54701 }
54702
54703 p = zscript_insert_config_variable(the_config, p, name, val);
54704 }
54705 else
54706 {
54707 /* global variable */
54708 p = the_config->head;
54709 zscript_insert_config_variable(the_config, NULL, name, val);
54710 the_config->head->next = p;
54711 }
54712 }
54713 }
54714
54715 the_config->dirty = TRUE;
54716 }
54717 }
54718
54719
54720
54721 /* zscript_set_config_int:
54722 * Writes an integer to the configuration file.
54723 */
54724 void zscript_set_config_int(const char *section, const char *name, int32_t val)
54725 {
54726 char buf[32], tmp[32];
54727 uszprintf(buf, sizeof(buf), uconvert_ascii("%d", tmp), val);
54728 zscript_set_config_string(section, name, buf);
54729 }
54730
54731
54732
54733 /* zscript_set_config_hex:
54734 * Writes a hexadecimal integer to the configuration file.
54735 */
54736 void zscript_set_config_hex(const char *section, const char *name, int32_t val)
54737 {
54738 char buf[32], tmp[32];
54739
54740 if (val >= 0)
54741 {
54742 uszprintf(buf, sizeof(buf), uconvert_ascii("%X", tmp), val);
54743 zscript_set_config_string(section, name, buf);
54744 }
54745 else
54746 zscript_set_config_string(section, name, uconvert_ascii("-1", buf));
54747 }
54748
54749
54750
54751 /* zscript_set_config_float:
54752 * Writes a float to the configuration file.
54753 */
54754 void zscript_set_config_float(const char *section, const char *name, float val)
54755 {
54756 char buf[32], tmp[32];
54757 uszprintf(buf, sizeof(buf), uconvert_ascii("%f", tmp), val);
54758 zscript_set_config_string(section, name, buf);
54759 }
54760
54761
54762
54763 /* zscript_set_config_id:
54764 * Writes a driver ID to the configuration file.
54765 */
54766 void zscript_set_config_id(const char *section, const char *name, int32_t val)
54767 {
54768 char buf[32], tmp[32];
54769 int32_t v[4];
54770 int32_t pos = 0;
54771 int32_t i;
54772
54773 if (val < 256)
54774 {
54775 uszprintf(buf, sizeof(buf), uconvert_ascii("%d", tmp), val);
54776 }
54777 else
54778 {
54779 v[0] = (val>>24)&0xFF;
54780 v[1] = (val>>16)&0xFF;
54781 v[2] = (val>>8)&0xFF;
54782 v[3] = val&0xFF;
54783
54784 for (i=0; (i<4) && (v[i]) && (v[i] != ' '); i++)
54785 pos += usetc(buf+pos, v[i]);
54786
54787 usetc(buf+pos, 0);
54788 }
54789
54790 zscript_set_config_string(section, name, buf);
54791 }
54792
54793
54794
54795 /* _zscript_reload_config:
54796 * Internal helper to reload the configuration from allegro_init, in case
54797 * zscript_set_config_file was called before allegro_init.
54798 */
54799 void _zscript_reload_config(void)
54800 {
54801 if (config[0])
54802 {
54803 char *name = _al_ustrdup(config[0]->filename);
54804 zscript_set_config_file(name);
54805 _AL_FREE(name);
54806 }
54807 }
54808
54809
54810
54811 /* zscript_reload_config_texts:
54812 * Reads in a block of translated system text, looking for either a
54813 * user-specified file, a ??text.cfg file, or a language.dat#??TEXT_CFG
54814 * datafile object. If new_language is not NULL, the language config
54815 * variable will be set to new_language before reloading the
54816 * configuration files.
54817 */
54818 void zscript_reload_config_texts(const char *new_language)
54819 {
54820 char filename[1024], tmp1[128], tmp2[128];
54821 const char *name, *ext, *datafile;
54822 char *namecpy;
54823
54824 if (config_language)
54825 {
54826 zscript_destroy_config(config_language);
54827 config_language = NULL;
54828 }
54829
54830 if (new_language)
54831 zscript_set_config_string("system", "language", new_language);
54832
54833 name = zscript_get_config_string(uconvert_ascii("system", tmp1), uconvert_ascii("language", tmp2), NULL);
54834
54835 if ((name) && (ugetc(name)))
54836 {
54837 namecpy = _al_ustrdup(name);
54838 ustrlwr (namecpy);
54839 if ((ustrlen(namecpy)<4) || (ustricmp(namecpy+uoffset(namecpy, -4), uconvert_ascii("text", tmp1)) != 0))
54840 ext = uconvert_ascii("text.cfg", tmp1);
54841 else
54842 ext = uconvert_ascii(".cfg", tmp1);
54843
54844 datafile = uconvert_ascii("language.dat", tmp2);
54845
54846 if (find_allegro_resource(filename, namecpy, ext, datafile, NULL, NULL, NULL, sizeof(filename)) == 0)
54847 {
54848 _AL_FREE(namecpy);
54849 zscript_load_config_file(&config_language, filename, NULL);
54850 return;
54851 }
54852
54853 _AL_FREE(namecpy);
54854 }
54855
54856 config_language = (struct ZSCRIPT_CONFIG*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG));
54857 if (config_language )
54858 {
54859 config_language ->head = NULL;
54860 config_language ->filename = NULL;
54861 config_language ->dirty = FALSE;
54862 }
54863 }
54864
54865
54866
54867 /* zscript_get_config_text:
54868 * Looks up a translated version of the specified English string,
54869 * returning a suitable message in the current language if one is
54870 * available, or a copy of the parameter if no translation can be found.
54871 */
54872 const char *zscript_get_config_text(const char *msg)
54873 {
54874 char tmp1[256];
54875 const char *section;
54876 const char *umsg;
54877 const char *s;
54878 const char *ret = NULL;
54879 char *name;
54880 ZSCRIPT_CONFIG_HOOK *hook;
54881 ZSCRIPT_CONFIG_ENTRY *p;
54882 int32_t c, pos, size;
54883 ASSERT(msg);
54884
54885 /* Hack: the inline definition of install_allegro() from 4.2.0 calls
54886 * zscript_get_config_text() even before Allegro has been initialised, leading
54887 * to a crash in get_executable_name(). To retain binary compatibility
54888 * we check for this case.
54889 */
54890 if (_allegro_count == 0)
54891 {
54892 return msg;
54893 }
54894
54895 zscript_init_config(TRUE);
54896
54897 section = uconvert_ascii("[language]", tmp1);
54898
54899 /* allocate memory and convert message to current encoding format */
54900 if (need_uconvert(msg, U_ASCII, U_CURRENT))
54901 {
54902 size = uconvert_size(msg, U_ASCII, U_CURRENT);
54903 umsg = (char*)_AL_MALLOC_ATOMIC(size);
54904 if (!umsg)
54905 {
54906 *allegro_errno = ENOMEM;
54907 return empty_string;
54908 }
54909
54910 name = (char*)_AL_MALLOC_ATOMIC(size);
54911 if (!name)
54912 {
54913 _AL_FREE((char *)umsg); /* remove constness */
54914 *allegro_errno = ENOMEM;
54915 return empty_string;
54916 }
54917
54918 do_uconvert(msg, U_ASCII, (char*)umsg, U_CURRENT, size);
54919 }
54920 else
54921 {
54922 umsg = msg;
54923 name = (char*)_AL_MALLOC_ATOMIC(ustrsizez(msg));
54924 if (!name)
54925 {
54926 *allegro_errno = ENOMEM;
54927 return empty_string;
54928 }
54929 }
54930
54931 s = umsg;
54932 pos = 0;
54933
54934 while ((c = ugetxc(&s)) != 0)
54935 {
54936 if ((uisspace(c)) || (c == '=') || (c == '#'))
54937 pos += usetc(name+pos, '_');
54938 else
54939 pos += usetc(name+pos, c);
54940 }
54941
54942 usetc(name+pos, 0);
54943
54944 /* check for hooked sections */
54945 hook = config_hook;
54946
54947 while (hook)
54948 {
54949 if (ustricmp(section, hook->section) == 0)
54950 {
54951 if (hook->stringgetter)
54952 {
54953 ret = hook->stringgetter(name, umsg);
54954 break;
54955 }
54956 }
54957
54958 hook = hook->next;
54959 }
54960
54961 if (!ret)
54962 {
54963 /* find the string */
54964 p = zscript_find_config_string(config_override, section, name, NULL);
54965
54966 if (!p)
54967 {
54968 p = zscript_find_config_string(config[0], section, name, NULL);
54969
54970 if (!p)
54971 p = zscript_find_config_string(config_language, section, name, NULL);
54972 }
54973
54974 if (p)
54975 {
54976 ret = (p->data ? p->data : empty_string);
54977 }
54978 else
54979 {
54980 /* no translation, so store off this value in the file */
54981 p = config_language->head;
54982 zscript_insert_config_variable(config_language, NULL, name, umsg);
54983 config_language->head->next = p;
54984 ret = config_language->head->data;
54985 }
54986 }
54987
54988 /* free memory */
54989 if (umsg!=msg)
54990 _AL_FREE((char*) umsg); /* remove constness */
54991
54992 _AL_FREE(name);
54993
54994 return ret;
54995 }
54996
54997
54998
54999 /* zscript_add_unique_config_name
55000 * Helper to add a name to a list of names.
55001 */
55002 int32_t zscript_add_unique_config_name(const char ***names, int32_t n, char const *name)
55003 {
55004 int32_t i;
55005 /* FIXME: use better search algorithm */
55006 for (i = 0; i < n; i++)
55007 if (!ustrcmp((*names)[i], name))
55008 return n;
55009
55010 *names = (const char**)_al_sane_realloc((void *)*names, (n + 1) * sizeof **names);
55011 (*names)[n] = name;
55012 return n + 1;
55013 }
55014
55015
55016
55017 /* zscript_attach_config_entries
55018 * Helper function to attach key or section names to a list of strings.
55019 */
55020 int32_t zscript_attach_config_entries(ZSCRIPT_CONFIG *conf, const char *section, int32_t n, const char ***names, int32_t list_sections)
55021 {
55022 ZSCRIPT_CONFIG_ENTRY *p;
55023 char section_name[256];
55024 int32_t in_section;
55025
55026 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
55027
55028 if (conf)
55029 {
55030 p = conf->head;
55031
55032 /* If section is NULL, only initial, section-less entries are used. */
55033 if (ugetc(section_name))
55034 in_section = FALSE;
55035 else
55036 in_section = TRUE;
55037
55038 while (p)
55039 {
55040 if (p->name)
55041 {
55042 /* a section start is just a list entry enclosed in [] */
55043 if (ugetc(p->name) == '[' && ugetat(p->name, -1) == ']')
55044 {
55045 if (list_sections)
55046 {
55047 n = zscript_add_unique_config_name(names, n, p->name);
55048 }
55049 in_section = (ustricmp(section_name, p->name) == 0);
55050 }
55051 else if (in_section && !list_sections)
55052 {
55053 n = zscript_add_unique_config_name(names, n, p->name);
55054 }
55055 }
55056 p = p->next;
55057 }
55058 }
55059 return n;
55060 }
55061
55062
55063
55064 /* list_config_entires:
55065 * Returns the names of all config entries in a section. The names parameter is
55066 * a pointer to a strings array that will contain the config keys. If it points to
55067 * a NULL pointer, it will be allocated, or else re-allocated accordingly. The
55068 * return value tells how many valid string pointers it contains after the
55069 * function returns.
55070 */
55071 int32_t zscript_list_config_entries(const char *section, const char ***names)
55072 {
55073 int32_t n = 0;
55074 n = zscript_attach_config_entries(config_override, section, n, names, 0);
55075 n = zscript_attach_config_entries(config[0], section, n, names, 0);
55076 return n;
55077 }
55078
55079
55080
55081 /* zscript_list_config_sections:
55082 * Returns the names of all current config sections, enclodes in []. The names
55083 * parameter and return value is like in list_config_entires above.
55084 */
55085 int32_t zscript_list_config_sections(const char ***names)
55086 {
55087 int32_t n = 0;
55088 n = zscript_attach_config_entries(config_override, NULL, n, names, 1);
55089 n = zscript_attach_config_entries(config[0], NULL, n, names, 1);
55090 return n;
55091 }
55092
55093
55094
55095 /* zscript_free_config_entries:
55096 * Frees the entries list returned by list_config_entires or
55097 * zscript_list_config_sections again.
55098 */
55099 void zscript_free_config_entries(const char ***names)
55100 {
55101 _AL_FREE(*names);
55102 *names = NULL;
55103 }
55104
55105 225833 int32_t FFScript::Distance(double x1, double y1, double x2, double y2)
55106 {
55107 225833 double x = (x1-x2);
55108 225833 double y = (y1-y2);
55109 225833 double sum = (x*x)+(y*y);
55110 //if(((int32_t)sum) < 0)
55111 //{
55112 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
55113 // return -10000;;
55114 //}
55115 225833 sum *= 1000000.0;
55116 225833 double total = sqrt(sum)*10;
55117 225833 return int32_t(total);
55118 }
55119
55120 int32_t FFScript::Distance(double x1, double y1, double x2, double y2, int32_t scale)
55121 {
55122 double x3 = x1+(x2-x1)/scale;
55123 double y3 = y1+(y2-y1)/scale;
55124 //double sum = (x*x)+(y*y);
55125 //if(((int32_t)sum) < 0)
55126 //{
55127 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
55128 // return -10000;
55129 //}
55130 //sum *= 1000000.0;
55131 //double total = sqrt(sum)*10;
55132 //return int32_t(total*scale);
55133 return (FFCore.Distance(x1, y1, x3, y3)*scale);
55134 }
55135
55136 int32_t FFScript::LongDistance(double x1, double y1, double x2, double y2)
55137 {
55138 double x = (x1-x2);
55139 double y = (y1-y2);
55140 double sum = (x*x)+(y*y);
55141 //if(((int32_t)sum) < 0)
55142 //{
55143 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
55144 // return -10000;;
55145 //}
55146 double total = sqrt(sum);
55147 return int32_t(total);
55148 }
55149
55150 int32_t FFScript::LongDistance(double x1, double y1, double x2, double y2, int32_t scale)
55151 {
55152 double x3 = x1+(x2-x1)/scale;
55153 double y3 = y1+(y2-y1)/scale;
55154 //double sum = (x*x)+(y*y);
55155 //if(((int32_t)sum) < 0)
55156 //{
55157 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
55158 // return -10000;
55159 //}
55160 //sum *= 1000000.0;
55161 //double total = sqrt(sum)*10;
55162 //return int32_t(total*scale);
55163 return (FFCore.LongDistance(x1, y1, x3, y3)*scale);
55164 }
55165
55166 void FFScript::do_distance()
55167 {
55168 double x1 = double(ri->d[rSFTEMP] / 10000.0);
55169 double x2 = double(ri->d[rINDEX] / 10000.0);
55170 double y1 = double(ri->d[rINDEX2] / 10000.0);
55171 double y2 = double(ri->d[rEXP1] / 10000.0);
55172
55173 int32_t result = FFCore.Distance(x1, x2, y1, y2);
55174 //ret = result*10000;
55175
55176 }
55177
55178 38512918 bool command_is_wait(int command)
55179 {
55180
2/2
✓ Branch 0 taken 38508066 times.
✓ Branch 1 taken 4852 times.
38512918 switch (command)
55181 {
55182 case WAITFRAME:
55183 case WAITDRAW:
55184 case WAITTO:
55185 case WAITEVENT:
55186 case WAITFRAMESR:
55187 4852 return true;
55188 }
55189 38508066 return false;
55190 38512918 }
55191
55192 38510935 bool command_uses_comparison_result(int command)
55193 {
55194
2/2
✓ Branch 0 taken 1091140 times.
✓ Branch 1 taken 37419795 times.
38510935 switch (command)
55195 {
55196 case GOTOTRUE:
55197 case GOTOFALSE:
55198 case GOTOMORE:
55199 case GOTOLESS:
55200 case SETTRUE:
55201 case SETTRUEI:
55202 case SETFALSE:
55203 case SETFALSEI:
55204 case SETMOREI:
55205 case SETLESSI:
55206 case SETMORE:
55207 case SETLESS:
55208 1091140 return true;
55209 }
55210 37419795 return false;
55211 38510935 }
55212
55213 485131 bool command_could_return_not_ok(int command)
55214 {
55215
2/2
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 483668 times.
485131 switch (command)
55216 {
55217 case 0xFFFF:
55218 case EWPNDEL:
55219 case GAMECONTINUE:
55220 case GAMEEND:
55221 case GAMERELOAD:
55222 case GAMESAVECONTINUE:
55223 case GAMESAVEQUIT:
55224 case ITEMDEL:
55225 case LWPNDEL:
55226 case NPCKICKBUCKET:
55227 case SETSCREENDOOR:
55228 case SETSCREENENEMY:
55229 1463 return true;
55230 }
55231 483668 return false;
55232 485131 }
55233
55234 const script_command& get_script_command(int command)
55235 {
55236 return ZASMcommands[command];
55237 }
55238
55239 99021924 int32_t get_combopos_ref(int32_t pos, int32_t layer)
55240 {
55241 99021924 return layer * 176 + pos;
55242 }
55243
55244 94370 int32_t combopos_ref_to_pos(int32_t combopos_ref)
55245 {
55246 94370 return combopos_ref % 176;
55247 }
55248
55249 38089 int32_t combopos_ref_to_layer(int32_t combopos_ref)
55250 {
55251 38089 return combopos_ref / 176;
55252 }
55253
55254